Things are stabilizing and still changing in the realm of WebSocket support. I’ll quickly summarize the current state of WebSocket support in various browsers and highlight the differences in versions.
WebSocket Transport Specification
The WebSocket transport specification was recently moved from HTML5 to the IETF. There’s a useful diff comparing IETF WebSocket draft 2 and 3. Most of the changes are just text clarifications, with some minor refinements of Close, Ping, and Pong. Current browsers support Draft 75 and Draft 76, the two versions prior to moving to the IETF. There are some slight differences in these versions which Comet servers such as Hookbox currently address, and there are still some issues with getting proper cross-domain messaging working correctly with these drafts.
ws:// and wss://
If you weren’t paying attention in the past year or so, one major change it that the specification defines ws:// and wss:// to define normal and secured WebSocket servers, instead of the http:// and https:// that web developers are familiar with, which is a nice improvement to differentiate between server types.
All non-IE desktop browsers currently have support in either their latest development or production releases. Support is as follows.
- Chrome 5
- Safari 5.0
- Firefox 4 beta (Firefox 4 WebSockets will be disabled by default)
- Chrome 6, 7, and 8
- Safari 5.02
- Opera 10.70
Currently there are no known mobile browsers with WebSocket support. The development version of Apple iOS 4.0 had support but removed it from production. It is believed the iOS 4.2 will ship with WebSocket enabled, and that Android will soon support it as well.
Update: iOS 4.2 and Blackberry 6 currently support WebSockets.
There are two common approaches by toolkits:
- Provide an API that looks like WebSocket, and fallback to other techniques if WebSocket isn’t available. Examples include Hookbox, dojox.Socket, Socket.IO, web-socket-js, Comet Session Protocol compliant toolkits, and others.
- Provide a higher-level API using pubsub or some other messaging protocol, and use WebSocket or whatever other transport is available that is the fastest and safest option. Examples include CometD, Lightstreamer, Bayeux protocol compliant servers, and others.
While the jury is still out on support in Internet Explorer 9 and
mobile browsers there are some issues to resolve with the protocol, WebSockets have arrived, are in much wider use than a year ago, and toolkits and servers have emerged to make working with Comet far easier than ever.