5 ms·
Is there a reason why a proper websocket connection along with the client pinging the server is preferable over long-polling?
by natejenkins 13y ago
Is there a reason why a proper websocket connection along with the client pinging the server is preferable over long-polling?
- atto 13y agoYes, for a few reasons — most are application specific, though. An active websocket connection does have a faster response time than a regular HTTP connection ([1]). The difference here isn't a ton, but may affect real-time applications. The packets are also smaller, so less overhead if you're sending many. The biggest difference I saw is that when the client or server needs to send several quick requests (many within a couple second), long polling breaks down. From the spec ([2]), "Once the server sends a long poll response, typically the client immediately sends a new long poll request." This delay can add up, and is not pure full duplex. Chunked responses help for server -> client, but client -> server still has the same issues. [1] http://eng.42go.com/secure-websockets-vs-https-benchmark/ http://eng.42go.com/secure-websockets-vs-https-benchmark/ [2] http://tools.ietf.org/html/draft-loreto-http-bidirectional-07#section-2.1 http://tools.ietf.org/html/draft-loreto-http-bidirectional-0...
- natejenkins 13y agoAwesome stuff, thanks. Your second point could explain some of the mysterious non-updates that I've seen from time-to-time when using faye with long-polling behind nginx.