A introduction to websockets.
To make a long story short websockets allow us to create a pipeline between a web client and a server. Which is great because we can push and pull all kind of data through it. This in turn allows us to create highly responsive web applications that may update information over multiple sessions. Sound awesome doesn’t it. There’s just one catch, and you can probably guess what it is. That’s right, it’s not universally accepted by all browser or containers. Worse yet, most browsers that are currently in use have very poor to no support for it yet. And the same can be said for quite the percentage of web containers out there. Luckily we can use SocksJS. This library actually checks if it is possible to set up a websocket. And, when this is not the case, sets up a default fallback. This means that if a websocket connection cannot be created the SocksJS implementation will fall back to long pulling. Giving us the same behavior as before only at a higher performance cost. The SocksJS api is the same as the one for websockets. This allows us to change from a websockets implementation to a SocksJS implementation with minimal changes. So if you want to create a highly responsive webapp which updates as soon as new information arrives SocksJS is the way to go.