Thanks, will change it to this: Session.close(new CloseReason(CLOSED_ABNORMALLY, "IOE on write"))
The problem happened when we updated Tomcat, meaning that all existing WebSocket connections were closed. Then after Tomcat restart, the client apparently reconnected, but this reconnect was disconnected within a second by the client. Or does this error mean that it was closed by the server? java.io.IOException: An established connection was aborted by the software in your host machine This problem happened only with this one connection, while there were several other connections which did not have any problems. -Harri -----Original Message----- From: Mark Thomas <ma...@apache.org> Sent: torstai 22. toukokuuta 2025 9.50 To: users@tomcat.apache.org Subject: Re: WebSocket session is never closed 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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org