
WebSockets: Stable and Ready for Developers - leggetter
http://www.sitepoint.com/websockets-stable-and-ready-for-developers/
======
factorialboy
At Review19 - <http://review19.com> \- we are primarily using web sockets but
we have fallback / failover transports in place.

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!

~~~
factorialboy
And.. umm.. discovered couple of hours ago that things surprisingly work great
on IE9 and apart from CSS disabilities fairly well in IE8.

Of course, hard to say its production ready for all kinds of web apps, you
must still choose based on your specific situation.

------
darklajid
"Stable and ready for developers" and mixing it with links to the .Net
framework 4.5 beta documentation seems off.

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.

~~~
rada
It seems "off" because it is:

<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.

~~~
majke
<shameless plug>

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>

~~~
leggetter
Great idea. Exactly what somebody should have done with HTTP Long-Polling and
Streaming (XHR, IFRAME, ActiveX etc.) but without a standardised API it was
difficult. The WebSockets API let's us do this.

------
cft
Huh? Android default browser (and most importantly, WebView) does not support
WebSockets, and has no visible plans to support it. IE8/9 do not support
WebSockets.

~~~
leggetter
Some expect Chrome for Android to become the default browser
(<http://www.wired.com/gadgetlab/2012/02/chrome-android/>) and if that happens
the WebSockets will be supported. Firefox for Android also supports
WebSockets.

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.

------
rizwan
One of the very _real_ issues with WebSockets is that they don't work often
over mobile networks, with invisible proxying, etc.

Unless you go with something like Socket.IO, WebSockets alone would never be a
viable solution.

~~~
leggetter
From my experience, working at Pusher and dealing with support for the past
year, WebSockets do work over a mobile 3G connection when you use an SSL
(wss://) connection. I tether (laptop -> mobile -> mobile data) quite a bit
whilst travelling and my mobile data provider, O2, do all sorts of annoying
things with dat (stop whitespace, inject JavaScript), but my WebSocket
connections work flawlessly.

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.

------
pippy
Websockets are great, but apache and nginx are still yet to support them out
of the box. You have to recompile nginx with a module and apache has to have a
custom mod.

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.

~~~
leggetter
When it comes to nginx and apache you can always go down the hosted realtime
infrastructure route. That way you can use WebSockets in your client (app) but
you don't need to worry about installing mods or handling the persistent
connections on your server.

See: [http://www.leggetter.co.uk/real-time-web-technologies-
guide#...](http://www.leggetter.co.uk/real-time-web-technologies-guide#hosted-
services)

------
tnash
Does anybody know how fast connecting to a WebSockets server is? How does it
compare to connecting over http? I was interested in the ws:// uri scheme as I
was unaware of that. Is there a future scenario where we could connect to a
WebSockets server directly through the browser without first connecting over
http and then with js?

------
VikingCoder
I would really love a free C# implementation of a Socket.IO WebSocket, with as
few external dependencies as possible.

~~~
leggetter
Are their commercial versions of socket.io for C# available? When it comes to
.NET people tend to go with signalR (which I think has WebSocket support but
not within ISS - until Windows 8 server), SuperWebsocket or XSockets.

------
leggetter
By a guy from Microsoft so plenty of MS examples/links, but a good overview of
WebSockets never the less. I'm interested to hear how many of use will ever
actually use the `WebSocket` object? Will we (developers) always use a library
offering a layer of abstraction and the real core functionality that we need.

~~~
TazeTSchnitzel
The WebSocket API is very simple, there wouldn't be much need to abstract it.

~~~
leggetter
The point in abstraction in this case is to add additional functionality.

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...](http://www.sitepoint.com/websockets-stable-and-ready-
for-developers/#comment-1043114)

------
wowfat
On a related note we put out a tech demo showing nodejs and socketio recently.
<http://www.webdigi.co.uk/fun/space/> It uses iPhone accelerometer to control
the ship on your browser game!

------
skeltoac
I was hoping to read an article about how WebSockets are more stable and ready
today than the last time I checked.

------
Roboprog
Microsoft technology examples. I am a-feared. Are there wrappers in jQuery or
Prototype (et al) for browser side WebSockets access yet, so I only need to
worry about _if_ it is supported, rather than how?

Similarly, what does it take to support this on the server side? (in a *nix
environment)

