Java SockJS Spring client and message size

后端 未结 2 1121
名媛妹妹
名媛妹妹 2020-12-29 14:43

Using SockJS java client, I am trying to connect to Spring sockjs server and is getting error 1009 for messages (without headers) of ~20Kb. Javascript library works fine.

相关标签:
2条回答
  • 2020-12-29 15:20

    If you're doing it like this:

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

    Try:

    stompClient.setInboundMessageSizeLimit(your_message_size_limit);
    
    0 讨论(0)
  • 2020-12-29 15:44

    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.

    0 讨论(0)
提交回复
热议问题