DEV Community

loading...

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

Collapse
dunglas profile image
Kévin Dunglas

Does the problem occur if the connection is using HTTPS? Most old proxies aren't able to do HTTPS decryption, and so cannot read the headers.
Also, instead of a custom long polling system, you could continue to use SSE. It's perfectly valid for the SSE server to close the connection after every push (as in long polling). By using this workaround you still benefit from the EventSource class. You can even go one step further and detect is the connection is using HTTP/1 or HTTP/2. If it is using HTTP/1, you can close the connection after every event for compatibility with old proxies, and continue to use a persistent connection with HTTP/2 (because AFAIK all modern proxies supporting HTTP/2 support SSE too).

Collapse
miketalbot profile image
Mike Talbot Author

It's a very good point. We serve HTTP/2 (via AWS Cloud Front). Now what the client browser is getting I don't know - yet. I'll report back if I find any more information there.

Collapse
sjoerd82 profile image
Sjoerd82

Did you get the insights on this? For my application SSE seems a very good fit, but your story put me on guard.

If by forcing a HTTPS connection (which by now should be widely acceptable, if not flat out the default for normal everyday applications) this issue is mitigated, then that is valuable knowledge to add to the equation here..

Thread Thread
kenricashe profile image
Kenric Ashe

Sjoerd82 in your experience, assuming you force HTTPS, has SSE been stable for you?

Collapse
kenricashe profile image
Kenric Ashe

I would also like to know whether HTTPS solves the issue. Thank you.

Collapse
kenricashe profile image
Kenric Ashe

Hello Kévin, having just found this article and comments a year after they were published, I am curious if you have experienced any issues with your proposed workarounds. In your opinion, is SSE production ready? I am at the point where I am ready to load test my app and thus I hope the answer is yes. ;-)

Collapse
dunglas profile image
Kévin Dunglas

Hi @kenricashe . Yes, according to me SSE is totally suitable for production. I use it in prod for years on my own projects and I also manage a SaaS product built on top of SSE and the Mercure protocol, which have many customers and is serving a huge number of SSE connections every days without problems (mercure.rocks).

Forem Open with the Forem app