Recently I ran into a strange error in our Wicket application that uses Wicket's native WebSockets:
java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method
As far as I understand the problem, we are trying to send more messages through one connection at the same time. Since we push messages on connections from background services/threads, this is very likely.
Looking at the JSR 356 API I was found that
If the websocket connection underlying this RemoteEndpoint is busy sending a message when a call is made to send another one, for example if two threads attempt to call a send method concurrently, or if a developer attempts to send a new message while in the middle of sending an existing one, the send method called while the connection is already busy may throw an IllegalStateException.
I think that using synchronized versions of JavaxWebSocketConnection.sendMessage.. methods would be great idea.