I cannot find in any official documentation:
Does Cloudflare fully support Server-sent events (SSE)?
Can we return an event stream of arbitrary duration?
Or will that have a chance to generate HTTP
Error 524: a timeout occurred?
The language in those docs does not answere it clearly:
the origin did not provide an HTTP response before the default 100 second connection timed out
suggests it works, because a response (stream) would be returned immediately
If you regularly run HTTP requests that take over 100 seconds to complete […], move those processes behind a subdomain not proxied (grey clouded)
suggests request completion is the criterion.
Some similar questions, but they were auto-closed and locked before anybody answered:
We need to have an official answer to whether this is supported.
Random bump because I currently have this question open with Cloudflare official support, and I do not want it to be auto-closed after 15 days so I can share the response with the community.
(It is really annoying to have to do that, Cloudflare.)
I think Cloudflare will return a 524 if no events are sent for 100 seconds. Otherwise you should be fine.
Cloudflare support kindly tested the current bahaviour for me, finding that it works when
running 30+ minutes, which way more than even Enterprise plan’s Error 524 limit or 6000s
This replication case confirms that:
- You should be able to do SSE with Cloudflare
- Error 524 only triggered if there is nothing from the server within 100s (in my replication, I keep sending every 2 seconds).
The described behaviour is certainly good enough for our use case.
There is one issue though:
For building production systems, the “undocumented feature seems to work for me today” approach is risky.
I’m following up with:
Can we get any certainty in writing that it will continue to work in the future, vs. just being an accidental implementation detail that works today but might stop any time overnight when Cloudflare changes its implementation?
This is what I mean by an “official answer”. It’s a product question.
I’ll post here once I get a reply.
I’m afraid we can’t guarantee whether anything will continue to work in the future.
As things might change and there are business decisions the product teams and the company need to make.
For example, support for SPDY protocol was deprecated a while ago, even though Cloudflare was one of the early adopters of SPDY protocol.
What I can assure you of, is that it’s not an accidental implementation details.
If you prefer something that officially supported, then you might want to consider WebSocket instead.
I think this makes it clear:
It’s working now, but does not have the same level of official support as e.g. WebSockets.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.