For the More Curious: socket.io WebSockets Library
The ws
npm
module is a perfectly fine
WebSockets implementation. But, admittedly, it is lacking in a few ways.
For example, WebSockets connections sometimes get dropped, but
the ws
module provides no way to automatically
reconnect.
Another problem is that ws
lives in Node.js.
That means that it is only available on the server. In your client-side
JavaScript, you would need to learn a totally different library that
accomplishes essentially the same task.
On top of that, on the client side you may have additional challenges: What if your browser is old and does not support WebSockets? You would need to provide a fallback mechanism of some kind.
socket.io
(socket.io) provides a solution ...
Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.