Description
Chandan opened SPR-13449 and commented
We are using spring version 4.1.5 and container is websphere(WAS). On server side we are using webscoket with SockJs -need fallback mechanism as WAS do not support websockets. Client is sockjs client -but instead of using messaging protocol (STOMP) over socket, we use JSON RPC. there could be more than 10 XHR requests per second. While doing some more load testing and negative scenarios -like abruptly closing browsers, idle period in browsers etc. we run in scenario where one of thread to send message acquire lock on object responseLock in method sendMessageInternal of class AbstractHttpSockJsSession -resulting in blocked state.
As perconnection handler is being used, subsequent requests are served but over period cpu usage increases as number of blocked threads increase.
Waiting for Monitor Lock on java/lang/Object@0x0000000022416F08 (This is object lock while sending message)
at org/springframework/web/socket/sockjs/transport/session/AbstractHttpSockJsSession.sendMessageInternal(AbstractHttpSockJsSession.java:279(Compiled Code))
at org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSession.sendMessage(AbstractSockJsSession.java:161(Compiled Code))
at com/avaya/cecobrowsega/cobrowse/service/handler/AgentConnectionHandlerImpl.send(AgentConnectionHandlerImpl.java:579(Compiled Code))
The send message is like this
@Override
public void send(String data) throws IOException {
webSocketSession.sendMessage(new TextMessage(data));
}
synchronzing the "webSocketSession" helps alleviate the issue -but I am not very sure what is happening here. Do we need to handle threading issue in our handler implementation or is there a contention at AbstractHttpSockJsSession
I saw a similar issue @ #17911 but then it was specific to STOMP
Affects: 4.1.5
Issue Links:
- Race condition when inbound message handling fails and StompSubProtocolHandler sends ERROR frame [SPR-13326] #17911 Race condition when inbound message handling fails and StompSubProtocolHandler sends ERROR frame