This endpoint is being called through Zuul. Quite randomly we get the phenomenom that events are getting "stuck", meaning another event needs to be sent to push the "stuck" event to the client. I'm not 100% sure but after investigation it seems due to the fact that "Transfer-Encoding = chunked" is used (automatically set by Undertow as well as by Tomcat for persistent connections).
Authors are also cautioned that HTTP chunking can have unexpected negative effects on the reliability of this protocol. Where possible, chunking should be disabled for serving event streams unless the rate of messages is high enough for this not to matter.
A work-around that seems to do the trick is making sure "enough traffic" is put on the stream (sending heartbeats each second), but this ofcourse is not desirable. We might as well use polling then.
Our setup is as follows:
Having an endpoint for SSE:
@RequestMapping(method = GET, produces = "text/event-stream;charset=UTF-8")
SseEmitter events();
This endpoint is being called through Zuul. Quite randomly we get the phenomenom that events are getting "stuck", meaning another event needs to be sent to push the "stuck" event to the client. I'm not 100% sure but after investigation it seems due to the fact that "Transfer-Encoding = chunked" is used (automatically set by Undertow as well as by Tomcat for persistent connections).
From [https://www.w3.org/TR/2011/WD-eventsource-20110208/]()
A work-around that seems to do the trick is making sure "enough traffic" is put on the stream (sending heartbeats each second), but this ofcourse is not desirable. We might as well use polling then.
We're kind of puzzled here. Do you have any clue?