Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since almost all platforms support Websocket, is it necessary to use Socket.io?


On top of its transport layer abstraction, socket.io adds various useful features including events, rooms, namespacing, efficient/convenient (de)serialization and network callbacks. I've been using it in websockets-only mode for various projects, because I don't care for slower / less reliable transports but still want the extra features.


While Websocket has good supports by browsers, it doesn't always handle switching between networks correctly, also, some networks disallow Websockets altogether, or drop websocket connections over HTTP, but not over HTTPS.

Socket.io (especially > 1.0) solves these issues with a layer by having smart reconnection mechanisms and starts by connecting over plain old HTTP longpolling, and upgrades the connection to use websockets if they're available and work.


It's not. There's an under-appreciated NPM module which is/was shared by Socket.IO that only handles the low-level WebSocket protocol for NodeJS:

https://www.npmjs.com/package/websocket.io

You can use that, and the built-in WebSocket object in modern browsers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: