6 ms·
I still don't really understand the difference between sockjs and socket.io.. or is it just aesthetic??
by polshaw 15y ago
I still don't really understand the difference between sockjs and socket.io.. or is it just aesthetic??
- majke 15y ago(I'm the SockJS author.) To some extent yes: aesthetics are an important difference :) Functionally you can do the same things on Socket.io as SockJS (but not the other way around). Socket.io provides high-level messaging abstractions, including really-high-level things like clustering with the redis backend. SockJS is only providing a WebSocket abstraction. SockJS has a well defined on-the-wire-http-fallbacks protocol: https://github.com/sockjs/sockjs-protocol https://github.com/sockjs/sockjs-protocol and thus there are SockJS server implementations for any language you pick. Finally, SockJS does work behind loadbalancers. So although the general functionality in Socket.io and SockJS is quite similar, the focus of the projects is different.
- liamk 15y agoMajke, does SockJS do reconnects and heartbeats? I really appreciate the client automatically reconnecting to the server after a server restart. With that said, I agree with your sentiments on Socket.IO's API. It's also worth noting that Socket.IO has some serious stability issues (read the 161 issues on Github)that would make me consider using SockJS.
- majke 15y ago> does SockJS do reconnects? No. WebSocket API doesn't do automatic reconnects. Also, it is impossible to get have it built-in: every single application will need to behave differently after reconnection! For example - you may want to make sure that your web app synchronised state after the reconnection (and that's very application specific thing). So, as with WebSockets, reconnecting is your responsibility. You're free to implement exponential backoff or any other thing you want. Frankly - that's quite simple. > does SockJS do heartbeats? SockJS server is expected to send simple frames once in a while to make sure that load balancer won't kill the long-polling connection. But this is not exposed to the user. Again, WebSocket API does not expose heartbeats AFAIK. And once again, implementing that on the application layer is not terribly complex and allows you to have behaviour that perfectly suits your needs.
- james2vegas 15y agoI pick Perl, but couldn't find a SockJS server implementation in that language. I could find one for socket.io though.
- majke 15y agoI have no clue what web servers are present in Perl world :) But seriously, writing a SockJS server is not an impossible task, feel encouraged! Here's some reference material: http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.2.1.html http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.2... https://github.com/sockjs/sockjs-protocol https://github.com/sockjs/sockjs-protocol