Hello,
We are using the SSE handler to post at interval some events.
Every time a user closes its browser tab, we've got the following exception:
java.nio.channels.ClosedChannelException: null
at
io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.safeToSend(AbstractFramedStreamSinkChannel.java:441)
~[classes/:na]
at
io.undertow.server.protocol.framed.AbstractFramedStreamSinkChannel.write(AbstractFramedStreamSinkChannel.java:395)
~[classes/:na]
at
org.xnio.conduits.StreamSinkChannelWrappingConduit.write(StreamSinkChannelWrappingConduit.java:57)
~[xnio-api-3.3.1.Final.jar:3.3.1.Final]
at
org.xnio.conduits.ConduitStreamSinkChannel.write(ConduitStreamSinkChannel.java:150)
~[xnio-api-3.3.1.Final.jar:3.3.1.Final]
at
io.undertow.channels.DetachableStreamSinkChannel.write(DetachableStreamSinkChannel.java:240)
~[classes/:na]
at
io.undertow.server.HttpServerExchange$WriteDispatchChannel.write(HttpServerExchange.java:1980)
~[classes/:na]
at
io.undertow.server.handlers.sse.ServerSentEventConnection$SseWriteListener.handleEvent(ServerSentEventConnection.java:456)
~[classes/:na]
at
io.undertow.server.handlers.sse.ServerSentEventConnection$2.run(ServerSentEventConnection.java:210)
[classes/:na]
at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:560)
[xnio-nio-3.3.1.Final.jar:3.3.1.Final]
at org.xnio.nio.WorkerThread.run(WorkerThread.java:462)
[xnio-nio-3.3.1.Final.jar:3.3.1.Final]
We guess it comes from the fact that the buffer is not empty at the time
the browser closes the connection. Having this stacktrace in the log files,
for every connection closed is a bit cumbersome for us. So, we were
wondering whether there was a mean to handle this special stacktrace. From
what we have seen, it is a log from a xnio WorkerThread but we don't wish
to mute all the error logs from this class. And we haven't seen any way to
catch the exception too.
Any ideas would be appreciated.
Thanks in advance.
Cédric.
PS: The example to reproduce the « issue » can be the one in attachment of
https://issues.jboss.org/browse/UNDERTOW-535.
You can run the example, open a browser at
https://localhost:8443/sse and
close the browser tab. The stacktrace should appear.