简体   繁体   English

Websocket替换?

[英]Websocket replacement?

I'm working on a project where a page, needs to be able to keep updated according to the state of a server. 我正在开发一个项目,其中一个页面需要能够根据服务器的状态保持更新。

I like websockets for this since they offer me a way of pushing messages from the server, but availability is a problem. 我喜欢websockets,因为它们为我提供了一种从服务器推送消息的方法,但可用性是一个问题。

I need generic way to do two way communication between a webserver and a browser-client. 我需要通用的方式在Web服务器和浏览器客户端之间进行双向通信。

I would like to be able to hold a large amount of clients on my server, so busywaiting clients is not a good solution. 我希望能够在我的服务器上容纳大量客户端,因此忙于等待客户端并不是一个好的解决方案。

I've looked at long pooling, but this seames like busy waiting on the clients part -- is it the only way to go if I need IE support? 我看了很长的游泳池,但是这个名字就像在客户端忙着等待 - 如果我需要IE支持,它是唯一的出路吗?

This question is only about the clients end of the transactions. 这个问题只是关于客户端的交易。

Do you need two-way communication? 你需要双向沟通吗? If not you should use SSE (Server-sent Events). 如果不是,您应该使用SSE (服务器发送的事件)。 They are also easier to simulate in IE (as SSE actually degrades gracefully to long-polling on older systems). 它们在IE中也更容易模拟(因为SSE实际上会降级为旧系统上的长轮询)。

Yes, you are correct there is a problem with longpolling, it tends to consume loads of resources. 是的,你是正确的longpolling有问题,它往往消耗大量的资源。

What you need is as i can see solution that has a fallback to HTTP longopolling for elder not Websockets API speaking browsers. 你需要的是因为我可以看到对于老年人而不是Websockets API说话浏览器的HTTP longopolling的回退解决方案。 SSE is a alternvative,but Websockets feels as a more convinent SSE是一种交替,但Websockets感觉更加便利

If you are running on the .NET plattform XSockets.NET can be a alternative, it supports Websockets (RFC6544 and Hybi00) and fallbacks on HTTP Longpolling when needed (ie IE ) 如果你在.NET平台上运行XSockets.NET可以替代它,它支持Websockets(RFC6544和Hybi00)和HTTP Longpolling在需要时(即IE)的回退

Have a look at http://xsockets.net 看看http://xsockets.net

Have you reviewed http://signalr.net/ ? 你有没有看过http://signalr.net/ Based on websockets but will gracefully downgrade to the nearest available component to support a socket type connection. 基于websockets但会优雅地降级到最近的可用组件以支持套接字类型连接。

Docs can be found here: https://github.com/SignalR/SignalR/wiki 文档可以在这里找到: https//github.com/SignalR/SignalR/wiki

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM