DEV Community

Discussion on: Server Sent Events are still not production ready after a decade. A lesson for me, a warning for you!

Collapse
 
kspeakman profile image
Kasey Speakman

Huge thanks for this article. Just found it while researching SSE. Very helpful as I also support clients with industrial networks.

Curious if you could still use SSE with clients/networks that support it. Have the server send a canary message right away upon connecting. If the client does not receive the canary message within a few seconds of connecting, then the client knows SSE is not safe to use and switches to long polling.

Collapse
 
miketalbot profile image
Mike Talbot ⭐ • Edited

Yes we still do that. We have a fall back to Long Polling with a pretty simple layer over it. If we don't get messages from SSE in response to an initial "ping" then we have a layer that basically flushes the stream every time (with a small debounce delay) and reopens it. We send a command to the server that says "treat" this stream as always close and reopen. Closing the stream does cause the proxies to forward on all of the data.