java.lang.IllegalStateException: Message will not be sent

Hi guys,

i get the error log from time to time. Is there a way to supress it?

java.lang.IllegalStateException: Message will not be sent because the WebSocket session has been closed

Looks like the connection between server and client has been disconnted and it tries to push an update to client, or does it has other reasons?

I’m not really sure from what part of Vaadin that message would come. Do you have a full stacktrace that you could share?

The most likely cause is anyways as you speculated that the end user has closed their browser tab at the same time when a change was pushed out.

1 Like

Hi sure, i think following lines are the most interessting ones

org.apache.tomcat.websocket.WsRemoteEndpointImplBase.writeMessagePart(WsRemoteEndpointImplBase.java:455)

java.lang.IllegalStateException: Message will not be sent because the WebSocket session has been closed

at com.vaadin.flow.server.communication.PushAtmosphereHandler.onStateChange(PushAtmosphereHandl
er.java:54)

Hi @Leif today i get this error again, do you know which way this communication is client to server or server to client?

I cant find the source of this issue

The situation in this case is that the server tries to push out changes to the client and at that moment notices that the client has closed the connection. In most cases, the closing of the connection is detected earlier so that Vaadin doesn’t even try to push out the update. The exception you see is mostly likely only happening when disconnect happens at exactly the same time as the push.

1 Like