Stomp spring web socket消息超出了大小限制
我正在我们的spring mvc web应用程序中实现spring web-socket。 但是当我尝试向端点发送一个非常大的消息时,我遇到了超过大小限制的消息。
我收到以下错误,
message:The 'content-length' header 68718 exceeds the configured message buffer size limit 65536 14:49:11,506 ERROR [org.springframework.web.socket.messaging.StompSubProtocolHandler] (http-localhost/127.0.0.1:8080-4) Failed to parse TextMessage payload=[13684590},..], byteCount=16384, last=true] in session vlsxdeol. Sending STOMP ERROR to client.: org.springframework.messaging.simp.stomp.StompConversionException: The 'content-length' header 68718 exceeds the configured message buffer size limit 65536 at org.springframework.messaging.simp.stomp.BufferingStompDecoder.checkBufferLimits(BufferingStompDecoder.java:148) [spring-messaging-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.messaging.simp.stomp.BufferingStompDecoder.decode(BufferingStompDecoder.java:124) [spring-messaging-4.1.6.RELEASE.jar:4.1.6.RELEASE]
这是我的配置
@MessageMapping("/user/sockettest" ) @SendTo("/topic/sockettestresult") public String sockAdd(ListId[] listIds) { .. SecurityContextHolder.getContext().getAuthentication().getPrincipal(); return stringRet; }
xml配置如下所示
客户端代码看起来像这样
function versionFiles() { stompClient.send("/testbrkr/user/sockettest", {}, JSON.stringify(listIds)); }
你能让我知道什么是好的解决方法。
答:如果您知道最大尺寸限制是多少
我正在研究如何进行部分消息传递,我会在发现并将其发布后立即发布
考虑
定义的
选项:
配置传入子协议消息的最大大小。 例如,当使用SockJS回退选项时,可以将STOMP消息作为多个WebSocket消息或多个HTTP POST请求接收。
使用WebSocketMessageBrokerConfigurer.configureWebSocketTransport(WebSocketTransportRegistration)
实现和setMessageSizeLimit()
就可以在注释配置中实现相同的function。
当设置默认值65kb时,我得到了类似的javascript errorr ..然后我将它设置为一些随机并再次得到一些错误,如
连接中断了
。 所以尝试增加时间限制,这对我有用。 实际上,当超出限制时,消息将被发送到数据包/帧中,当它从服务器接收响应时,它会超时。
您可以使用如下调整它
@EnableWebSocketMessageBroker public class AppWebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { ---- --- @Override public void configureWebSocketTransport(WebSocketTransportRegistration registration) { registration.setMessageSizeLimit(200000); // default : 64 * 1024 registration.setSendTimeLimit(20 * 10000); // default : 10 * 10000 registration.setSendBufferSizeLimit(3* 512 * 1024); // default : 512 * 1024 } --- }