Lurker News

Comments (140) 32 threads

Show all comments

Showing thread 12 of 32

lordlarm1 reply#
For simple one-directional communication (Server to client(s)) as shown in the example, it may for many people be simpler to use EventSource [1]

I've used this for UI's where the server continuously sends/pushes updates to the clients. Really handy, and multiple implementations and libraries available in most languages.
Of interest is perhaps also the spec [2]
[1]: https://developer.mozilla.org/en-US/docs/Web/API/EventSource
[2]: https://html.spec.whatwg.org/multipage/comms.html#the-events...

stephenr1 reply#
Due to it's nature, EventSource can be quite easily implemented using a polyfill for legacy browsers.

It's also MUCH easier to setup/run in a multi-layered stack (e.g. Pound/HAProxy > Varnish > App Server).
As per usual, WebSockets is what the "cool kids" use, even when it's often much less appropriate and much less flexible.

tokenizerrr1 reply#
So what would you use to implement the polyfill for IE10? Is there something more appropriate than websockets? If not, are we not back to square one where you may as well use websockets from the start?
stephenr1 reply#
There are multiple polyfills for EventSource - mostly all it needs is a working XHR implementation.

The key thing is that a proxy/load balancer doesn't need special cases to support EventSource like it needs (and often doesn't have) with websockets.

tokenizerrr4 replies#
And then you're polling instead of pushing.

Continue this thread — 4 replies