Stomp spring web socket消息超出了大小限制 [英] Stomp spring web socket message exceeds size limit

查看:3459
本文介绍了Stomp spring web socket消息超出了大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将spring web-socket实现到我们的spring mvc web应用程序中。但是当我尝试向端点发送一个非常大的消息时,我遇到了超过大小限制的消息。

I am implementing spring web-socket into our spring mvc web application. However I am running into message over size limits when I am trying to send a really big message to an endpoint.

我收到以下错误,

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配置类似于以下


The xml config looks like the following

<websocket:simple-broker prefix="/topic"/>

<websocket:message-converters register-defaults="false">
    <bean id="mappingJackson2MessageConverter" class="org.springframework.messaging.converter.MappingJackson2MessageConverter">
        <property name="objectMapper" ref="objectMapper"></property>
    </bean>
</websocket:message-converters>
</websocket:message-broker>

客户端代码如下所示

function versionFiles() {
        stompClient.send("/testbrkr/user/sockettest", {}, JSON.stringify(listIds));
    }

你能告诉我什么是好的解决办法。

Can you let me know what would be a good work-around.

答案:如果你知道什么是最大尺寸限制

Answer: If you know what would be the maximum size limit

 <websocket:transport message-size="75536" send-buffer-size="75536"></websocket:transport>

我正在研究如何进行部分消息传递,我会在发现后立即将其发布在此处让它工作

I am looking on how to do partial messaging, will post it here as soon as I find out and get it working

推荐答案

考虑< websocket:transport message-size =/> < websocket:message-broker> 定义的选项:


配置传入子协议消息的最大大小。
例如,当使用SockJS后备选项时,STOMP消息可能被接收为多个WebSocket消息
或多个HTTP POST请求。

Configure the maximum size for an incoming sub-protocol message. For example a STOMP message may be received as multiple WebSocket messages or multiple HTTP POST requests when SockJS fallback options are in use.

使用 WebSocketMessageBrokerConfigurer.configureWebSocketTransport(WebSocketTransportRegistration)实现并使用 setMessageSizeLimit()就此事而言。

The same can be achieved in annotation configuration using WebSocketMessageBrokerConfigurer.configureWebSocketTransport(WebSocketTransportRegistration) implementation and with the setMessageSizeLimit() on the matter.

这篇关于Stomp spring web socket消息超出了大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆