websocket传输数据大小限制_踩踏websocket:发送缓冲区大小超过允许的限制

在客户端我使用Stomp进行websocket连接,服务器端使用

Spring 4

客户端我做了配置

var socket = new SockJS(urlBase + "/" + contextroot+'/hello');

stompClient = Stomp.over(socket);

下面的代码每2秒执行一次,将数据发送到服务器

stompClient.send('/app/sendRequest/'+indexVal, {},

JSON.stringify({index : simIndex}));

服务器响应以下队列

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

在服务器端配置完成

消息响应在服务器端

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

几秒钟后,我收到错误消息

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

我尝试增加缓冲区大小,但一段时间后它给出相同的异常.一旦达到缓冲区大小.

我认为一旦发送消息,websocket会话缓冲区就不会被释放.

是否有相同的设置要求?

我错过了任何配置吗?

尝试在服务器端配置Web套接字.

在WebSocketConfig类中有这样的东西:

public void configureWebSocketTransport(WebSocketTransportRegistration registration) {

registration.setMessageSizeLimit(500 * 1024);

registration.setSendBufferSizeLimit(1024 * 1024);

registration.setSendTimeLimit(20000);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值