On 21/05/2025 10:37, Harri Pesonen wrote:
Hello,

We have a random problem with Apache Tomcat/9.0.100 in Windows, JDK 11.0.13.
We have seen this problem only once so far.
Problem is that WebSocket connection is apparently closed but there is no 
callback to @OnClose handler, which is implemented in @ServerEndpoint class.

That shouldn't happen. If you ever figure out what triggers this issue, do let us know. There might be an edge case we need to fix in the error handling.

<snip/>

I just implemented possible workaround for this problem by calling close() on 
the WebSocket when this IOException happens in the sendText() callback.
Now I am asking, do you think that this workaround will fix the problem, if it 
ever happens again?

It should do yes. You might want to call:

Session.close(new CloseReason(CLOSED_ABNORMALLY, "IOE on write"))

rather than

Session.close()

to signal to Tomcat that the session is being closed due to an error condition. It should step additional error events being triggered. But both methods should work.

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to