[ 
https://issues.apache.org/jira/browse/WICKET-6103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15168775#comment-15168775
 ] 

ASF subversion and git services commented on WICKET-6103:
---------------------------------------------------------

Commit b9e22fb42c6aad635990296705af232d23a8f2ca in wicket's branch 
refs/heads/wicket-7.x from [~mgrigorov]
[ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=b9e22fb ]

WICKET-6103 Synchronization on JSR 356 connection

Synchronize the send** and close() methods


> 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
>
> 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