3 ms·
Why socket.io instead of just plain websockets? Socket.io adds a lot of complexity in the client and the server. What commensurate benefit does it provide? htt
by josephg 9y ago
Why socket.io instead of just plain websockets? Socket.io adds a lot of complexity in the client and the server. What commensurate benefit does it provide?
http://caniuse.com/#feat=websockets http://caniuse.com/#feat=websockets
- Can_Not 9y agoSocket.io adds rooms/namespaces as a feature, automatically reconnects with effort to not have all clients reconnect at the same time, covers compatibility edgecases, heartbeat, timeouts, custom events, multiple transport methods, server side implementations in multiple languages, supports non-ws fallback for reasons that might not be browser compatibility, and a good API.
- aphextron 9y ago>Why socket.io instead of just plain websockets? Socket.io adds a lot of complexity in the client and the server. What commensurate benefit does it provide? The real reasoning is browser support. Socket.io supports automatic fallback to AJAX long polling if the client doesn't support websockets. It also standardizes the interface across clients. It's essentially to websockets what jQuery is to the DOM.
- always_good 9y agoFor one, it has message_id ackbacks so that you can have a request/response rpc style system. A basic feature for any websocket-heavy application. socket.send('login', [uname, pass], (err) => ...) And there are socket-io clients for most languages that can interop with a socket-io server, once again supporting message_id callbacks. Reconciling my own message_id + reconnect buffer system is not something I want to build on the client + server every time I build an application. People talk shit about socket.io and then never recommend an alternative that implements this fundamental feature. Without message_ids, I get flashbacks to working with IMAP.