[ 
https://issues.apache.org/jira/browse/WICKET-6103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Grigorov resolved WICKET-6103.
-------------------------------------
       Resolution: Fixed
    Fix Version/s: 8.0.0-M1
                   7.3.0

Thanks!

> Synchronization on JSR 356 connection
> -------------------------------------
>
>                 Key: WICKET-6103
>                 URL: https://issues.apache.org/jira/browse/WICKET-6103
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket-native-websocket
>    Affects Versions: 7.2.0
>         Environment: Tomcat 7.0.59, java8
>            Reporter: Jan Krakora
>            Assignee: Martin Grigorov
>             Fix For: 7.3.0, 8.0.0-M1
>
>
> Recently I ran into a strange error in our Wicket application that uses 
> Wicket's native WebSockets:
> {code}
> java.lang.IllegalStateException: The remote endpoint was in state 
> [TEXT_FULL_WRITING] which is an invalid state for called method
>       at 
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1175)
>       at 
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textStart(WsRemoteEndpointImplBase.java:1138)
>       at 
> org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:192)
>       at 
> org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)
>       at 
> org.apache.wicket.protocol.ws.javax.JavaxWebSocketConnection.sendMessage(JavaxWebSocketConnection.java:81)
>       at 
> org.apache.wicket.protocol.ws.api.WebSocketResponse.close(WebSocketResponse.java:92)
>       at 
> org.apache.wicket.protocol.ws.api.AbstractWebSocketProcessor.broadcastMessage(AbstractWebSocketProcessor.java:252)
>       at 
> org.apache.wicket.protocol.ws.api.AbstractWebSocketConnection.sendMessage(AbstractWebSocketConnection.java:43)
> ...
> {code}
> 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 
> bq. 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to