Thursday 13 February 2014

WebSockets - An Unexpected Journey

If your like me, your always looking at what is going to come next in the web world; and given an opportunity, will try to bring life to it.

When I was told to do a POC on websockets under grails...I lit up like a bulb. Finally, going to work on the fringes of technology and do something really cool.... I should humbly mention that I've almost been successful in putting POCs together... unless something is really off.

However, what started out as awesome really turned sideways pretty quickly. And to put a long story short - its just not ready. Huge lack in framework integration... I primarily work with Groovy/Grails...and they have 3 different plugins that hook to Atmosphere...and *none* of them work perfectly.

After 2 days of fighting, I was finally able to get Websockets working with NIO asynchronously. Very nice. Finally I thought, a working prototype.

Then came my good friend Apache httpd. Websocket support is native, but only with version 2.4! At the time of writing, this is the latest version. Andddd...you won't get a binary....which means you build from source...which means resolving some very nasty hidden dependencies.

I was going to show code on how I got it working, but I realize that this technology will most definitely evolve and become mainstream. After falling back, I tried good old fashioned long polling with simple jQuery...the results are not too shabby.

Bottomline, unless you have a highly time sensitive application (like real time tickers), really high volume of traffic that can potentially clog your server, complete autonomy on your production environment; I'd stick to old school polling.