Java SockJS Spring client and message size

自古美人都是妖i 提交于 2019-11-30 07:44:52

I stumbled with the same problem. It's all about the configuration of the client, not the server. You can create WebSocketContainer instance and configure it.

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.setDefaultMaxBinaryMessageBufferSize(your_size);
container.setDefaultMaxTextMessageBufferSize(your_size);
WebSocketClient transport = new StandardWebSocketClient(container);
WebSocketStompClient stompClient = new WebSocketStompClient(transport);

your_size - size in bytes.

If you're doing it like this:

SockJsClient sockJsClient = new SockJsClient(transports);
    WebSocketStompClient stompClient = new WebSocketStompClient(sockJsClient);

Try:

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