SSE connection closes immediately with Javalin 4.5.0
See original GitHub issueActual behavior (the bug) When upgrading from Javalin 4.4.0 to 4.5.0, SSE event streams stopped working. Rather than holding the stream open so events can be delivered asynchronously, the response stream is closed too soon.
Expected behavior Response stream remains open and async events delivered when published to the SseClient.
To Reproduce
Run:
public static void main(String[] args) {
final Javalin javalin = Javalin.create();
javalin.get("/sse", new SseHandler(client -> {
client.sendEvent("Sync Event");
new Thread(() -> {
while (true) {
client.sendEvent("Async event");
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
}
}).start();
}));
javalin.start(8080);
}
And then try to subscribe to the events:
curl -H 'Accept: text/event-stream' http://localhost:8080/sse
The sync event is always delivered and sometimes the first async event, but it doesn’t hold the connection open for later async events.
Additional context The actual application code is from Teku: https://github.com/ConsenSys/teku/blob/38a60ea76e14c240cbcecaccab1a4c4f8734b056/data/beaconrestapi/src/main/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/GetEvents.java#L52
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
I get the same issue with
.sse
. We use.get
so we can get the openapi annotations to be picked up as well.@ajsutton this should be fixed now !