Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to WebSockets

Tags:

websocket

I have been quite excited by the prospect of WebSockets. As I have built a few Desktop socket based games, and Web games in the past, I was keen to combine the two approaches to building multiplayer web-based games without a long-polling hack.

Since the news that Firefox and Opera have disabled websockets due to security issues (see here), is that the end of WebSockets for the near future?

If WebSockets are indeed dead (or postponed for the foreseeable future), are there any alternatives other than Long Polling?

like image 448
Codemwnci Avatar asked Dec 19 '10 12:12

Codemwnci


People also ask

What will replace WebSockets?

For applications that need low-latency, event-driven communication between endpoints, WebSockets has been the go-to choice, but WebTransport may change that. WebSockets is a technology that enables bidirectional, full-duplex communication between client and server over a persistent, single-socket connection.

Are WebSockets outdated?

Websockets are largely obsolete because nowadays, if you create a HTTP/2 fetch request, any existing keepalive connection to that server is used, so the overhead that pre-HTTP/2 XHR connections needed is lost and with it the advantage of Websockets.

Is SSE better than WebSocket?

SSEs are most appreciated in the cases like updating statuses, push notifications, newsletters and news feeds because they support mono-directional communication. Compared to WebSockets, SSE is faster and more suitable to set up.

Is long polling better than WebSockets?

Long Polling usually produces slightly higher average latency and significantly higher latency variability than WebSockets. WebSockets do support compression, but usually per-message.


1 Answers

WebSockets are alive and kicking. Only firefox 4 beta has disabled native WebSockets support, Chrome and Safari have not. Opera announced that they won't ship a release with it until the issues were addressed but never shipped a alpha/beta release with it turned on anyways.

In addition, a lot (perhaps most) of the projects that use WebSockets use the web-socket-js (Flash) fall-back. For those projects, when running on browsers with no WebSockets or with it disabled, web-socket-js will be used. It will be less efficient than native, but still much lower latency than long-polling.

But it's also important to remember that WebSockets is much younger than most of the other parts of HTML5 (part of the reason it was split off several months ago) and it is still very much in draft stage.

Also, the HyBi working group (responsible for drafting the WebSockets protocol) has just released a updated draft standard 04 that addresses the browser vendor security concerns (note in particular that the concerns are not because of a vulnerability in WebSockets but that WebSockets may be used to exploit vulnerabilities in HTTP intermediaries).

The discussion about WebSockets is still very active on HyBi. I expect there may be another draft with further improvements before it makes it into the next round of browser releases. The browser vendors all desire to solve the problem that WebSockets addresses (low-latency, low-overhead network communication from the browser) so the movement towards WebSockets is happening fast.

The current bump is just a bump. But regardless of how long the native implements take to finalize, you can still use WebSockets on every browser using web-socket-js.

Update:

The new HyBi protocol that addresses the security concern (among other things) is complete and is expected to be officially published this month (Nov 2011). HyBi-17 is the latest version of the spec.

With IE10 developer preview including WebSockets, Opera and Android's browser the only browsers that are not shipping a WebSockets implementation that is on by default (Opera's implementation can be manually enabled). I expect that will change soon and in the meantime web-socket-js has been updated to the HyBi protocol series and is still a good polyfill/shim for browsers without default support.

like image 164
kanaka Avatar answered Oct 14 '22 09:10

kanaka