Websocket java client Spring + Stomp: Transport error: ConnectionLostException

泄露秘密 提交于 2019-12-05 20:06:24

I had the same problem. Cause was recieving too big message which default STOMP Spring/Tomcat WS client cannot handle because it is not capable of partial messaging. This StackOverflow answer worked for me (I have set MAX_TEXT_MESSAGE_BUFFER_SIZE=20*1024*1024):

WebSocketContainer container = ContainerProvider.getWebSocketContainer();
container.setDefaultMaxTextMessageBufferSize(MAX_TEXT_MESSAGE_BUFFER_SIZE);
WebSocketClient wsClient = new StandardWebSocketClient(container);

Setting inboundMessageSizeLimit had no effect:

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