Socket.io
Socket.io is a javascript web application on nodejs. It uses diffents transports methods depending on the browser.
I use it on 2 purposes:
– make browser client refresh some ressources when there are a change: a news section for example.
– alert when there are simultaneous change of a ressource: a change on a planning (http://www.katagena.com/setagaya/demo.php)
I have 2 projects using this technology:
– a dashboard with live status from different server: uptime values will refresh live
– a magento extension with live update
Native Socket.io allow javascript to send message but you can find libraries in different langages. As my backend is in PHP, I use the PHP library http://elephant.io/.
Recently, I was blocked by a strange bug: “This socket.io server do not support websocket protocol. Terminating connection…”
As my server is just installed, I though it was a version issue but it was easier:
ElephantIO Client has a function to check the server, function named handshake. This function will check http://yourserver:yourport/socket.io/1/ and expect a response like “at9Huwk8khVAa5-flPVZ:60:60:websocket,htmlfile,xhr-polling,jsonp-polling”. It shows the list of supported protocol: websocket is present.
So I check the url use by the library and I had “http://yourserver:yourport//socket.io/1/”, with an extra slash. The result page is quite different and show only “Welcome to socket.io.”. That’s why I got the error: not because server didn’t support websocket but just because url was wrong.
At the end, your code should be:
Not: