Stomp over websocket : The send buffer size exceeded the allowed limit

元气小坏坏 提交于 2019-11-28 03:40:01

问题


At client side I am using Stomp for websocket connection and server side I am using Spring 4 It client side I did configuration as

var socket = new SockJS(urlBase + "/" + contextroot+'/hello');
stompClient = Stomp.over(socket);

Below code executed for every 2 second to send data to server

stompClient.send('/app/sendRequest/'+indexVal, {}, 
JSON.stringify({index : simIndex}));

Server respond to below queue

stompClient.subscribe('/queue/response', processResponseObj);

at server side configuration done as

<websocket:message-broker application-destination-prefix="/app">
   <!--<websocket:transport send-timeout="15000" message-size="1051648" send-buffer-size="1051648"/> -->
   <websocket:stomp-endpoint path="/hello">
       <websocket:sockjs />
   </websocket:stomp-endpoint>
   <websocket:stomp-broker-relay prefix="/topic, /queue"  />

    <websocket:message-converters>
        <beans:bean class="org.springframework.messaging.converter.MappingJackson2MessageConverter">
        <beans:property name="objectMapper" ref="objectMapper" />
       </beans:bean>
    </websocket:message-converters>

    </websocket:message-broker>

Message responsded as at server side

 messagingTemplate.convertAndSend("/queue/response",obj);

After some second I am getting error message

2014-10-24 16:39:33,869 ERROR et.messaging.SubProtocolWebSocketHandler: 330 - Terminating session id 'dkbzrkxp'
org.springframework.web.socket.handler.SessionLimitExceededException: The send buffer size 1147188 bytes for session 'dkbzrkxp exceeded the allowed limit 1051648
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sessionLimitReached(ConcurrentWebSocketSessionDecorator.java:162) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.checkSessionLimits(ConcurrentWebSocketSessionDecorator.java:150) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sendMessage(ConcurrentWebSocketSessionDecorator.java:105) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageToClient(StompSubProtocolHandler.java:276) ~[StompSubProtocolHandler.class:4.0.6.RELEASE]
    at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:326) ~[SubProtocolWebSocketHandler.class:4.0.6.RELEASE]
    at org.springframework.messaging.support.ExecutorSubscribableChannel$1.run(ExecutorSubscribableChannel.java:70) [ExecutorSubscribableChannel$1.class:4.0.6.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_20]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_20]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_20]
2014-10-24 16:39:33,871  WARN ort.session.WebSocketServerSockJsSession: 285 - Failed to send SockJS close frame: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
2014-10-24 16:39:33,875 ERROR et.messaging.SubProtocolWebSocketHandler: 330 - Terminating session id 'nro1ww4x'
org.springframework.web.socket.handler.SessionLimitExceededException: The send buffer size 1147188 bytes for session 'nro1ww4x exceeded the allowed limit 1051648
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sessionLimitReached(ConcurrentWebSocketSessionDecorator.java:162) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.checkSessionLimits(ConcurrentWebSocketSessionDecorator.java:150) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.sendMessage(ConcurrentWebSocketSessionDecorator.java:105) ~[ConcurrentWebSocketSessionDecorator.class:4.0.6.RELEASE]
    at org.springframework.web.socket.messaging.StompSubProtocolHandler.handleMessageToClient(StompSubProtocolHandler.java:276) ~[StompSubProtocolHandler.class:4.0.6.RELEASE]
    at org.springframework.web.socket.messaging.SubProtocolWebSocketHandler.handleMessage(SubProtocolWebSocketHandler.java:326) ~[SubProtocolWebSocketHandler.class:4.0.6.RELEASE]
    at org.springframework.messaging.support.ExecutorSubscribableChannel$1.run(ExecutorSubscribableChannel.java:70) [ExecutorSubscribableChannel$1.class:4.0.6.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_20]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_20]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_20]
2014-10-24 16:39:33,876  WARN ort.session.WebSocketServerSockJsSession: 285 - Failed to send SockJS close frame: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
2014-10-24 16:39:34,833 ERROR standard.StandardWebSocketHandlerAdapter:  55 - Closing due to exception for WebSocket session id=0

I tried with increasing buffer size also but after some time its giving same exception. once buffer size reached.

I think websocket session buffer not released once message delivered.

Is there any setting requird for same? Did i missed any configuration ?


回答1:


Try to configure the web socket on the server side. Something like this int the WebSocketConfig class:

 public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
    registration.setMessageSizeLimit(500 * 1024);
    registration.setSendBufferSizeLimit(1024 * 1024);
    registration.setSendTimeLimit(20000);
}



回答2:


Resolved by adding

 public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
registration.setMessageSizeLimit(102400* 1024); 
}


来源:https://stackoverflow.com/questions/26543904/stomp-over-websocket-the-send-buffer-size-exceeded-the-allowed-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!