Skip to content

SseEmitter IOException on HTTP Connection Close #33832

Closed
@alex-vukov

Description

@alex-vukov

The crash happens on HTTP2 every time the browser issues an EventSource close() and can be reproduced with this repo:

https://github.com/alex-vukov/spring-sse-issue

You can test by starting the application, opening the following URL from the browser https://localhost:8080/sse and after you receive some data clicking on the browser's stop button. It can also be reproduced in JavaScript with EventSource close(). The error happens only with the integrated Tomcat server and only over HTTP2. It doesn't happen with Jetty (you can test by switching the pom.xml with pom-jetty.xml). This is the exception which breaks the app and it is unhandled even though in the code I have emitter.send wrapped in try-catch:

java.io.IOException: null
        at org.apache.coyote.http2.Stream$StandardStreamInputBuffer.receiveReset(Stream.java:1516) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Stream.receiveReset(Stream.java:224) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Http2UpgradeHandler.reset(Http2UpgradeHandler.java:1739) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Http2AsyncUpgradeHandler.reset(Http2AsyncUpgradeHandler.java:43) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Http2Parser.readRstFrame(Http2Parser.java:318) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Http2AsyncParser$FrameCompletionHandler.completed(Http2AsyncParser.java:260) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.coyote.http2.Http2AsyncParser$FrameCompletionHandler.completed(Http2AsyncParser.java:167) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.tomcat.util.net.SocketWrapperBase$VectoredIOCompletionHandler.completed(SocketWrapperBase.java:1103) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper$NioOperationState.run(NioEndpoint.java:1654) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) ~[tomcat-embed-core-10.1.31.jar:10.1.31]
        at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions