83 points · by leggetter · 14y ago · 30 comments
What helps is the very awesome Socket.io abstraction, just mention websockets and a bunch of fallbacks in the config and get coding.
Must say having JavaScript on the server, the client and the data store is a huge advantage as well from a programming context perspective!
Of course, hard to say its production ready for all kinds of web apps, you must still choose based on your specific situation.
Sure, it can be stable. And ready is kind of subjective. But the 'Use this, now' feeling I got from the title was quickly nowhere to be found.
That said: I liked the whole walkthrough and general depth of the article.
http://caniuse.com/#feat=websockets
I would love to use web sockets in my app to replace long polling but without IE/Android, it's a non-starter.
That's exactly what I thought and that's why SockJS is there: https://github.com/sockjs/sockjs-client
a) start using SockJS
b) wait until enough browsers supports it
c) drop SockJS.
SockJS has a websocket-like API so no need to do major code changes when you switch.</shameless plug>
I can't 100% confirm Chrome will become the default but Google are very pro WebSockets so it would be very strange for them not to support and encourage their use.
There are fallback options in place that mean WebSockets can be used on Android but that tends to mean Flash lite also has to be installed.
Additionally, IE 10 supports WebSockets, and fallbacks exist- such as flash- to give support to earlier versions of IE.
"Production Ready", in this sense, means "finalized enough that you can feel secure about implementation", just like html5 and css 3. Should you rely on css 3 alone for old versions of IE? You need fallbacks, of course. But you can feel comfortable about implementing it (with progressive enhancement or graceful degredation) for support of less-able browsers.
Unless you go with something like Socket.IO, WebSockets alone would never be a viable solution.
In the same way that a WebSocket library can fallback from a WebSocket connection to a HTTP-based connection it can also first try ws:// and then fallback to wss:// - it's what our library does. The potential problem here of course is that you need an SSL certificate. When using Pusher that's not a problem, because we've bought one, but when using your own hosted solution that might mean dishing out money that you'd rather not.
When it's a case of writing in a line in nginx.conf for a proxy bypass or commenting out an apache module then it will be ready. Using port HTTP/port 80 is one of websockets strengths.
See: http://www.leggetter.co.uk/real-time-web-technologies-guide#...
The most obvious option, and something I thought might have become part of the WebSocket API, is auto-reconnection. To reconnect you need to create another WebSocket object and reattach all your event listeners. So, I'm convinced that the majority of people who use WebSockets will have to write their own custom code for this and will probably put it in their own little library which wraps around using WebSocket objects.
More info in the comment here: http://www.sitepoint.com/websockets-stable-and-ready-for-dev...
Similarly, what does it take to support this on the server side? (in a *nix environment)