3

I wrote a websocket server in Spring Boot and a client in Javascript. These work fine. I also wrote a second client in Java. When this one attempts to handle a frame after connecting to the host, I get this error:

org.springframework.web.socket.sockjs.client.WebSocketClientSockJsSession - Transport closed with CloseStatus[code=1009,  reason=The decoded text message was too big for the output buffer and the endpoint does not support partial messages]

A quick search showed that you can change the buffer size, but should I go this route right away? Should I try to compress the data in some way (I ask with little knowledge of how to go about that)?

  • I've found that you can enable server compression in the application.yml file, but I am not sure that it works on my websocket connection. – Jeff Aug 21 '18 at 18:14
  • 1
    Note that if you're echanging too much data, it might also be a design problem that would lead to poor performance in production environment (where the badwith and stability of the connection is not always here). – Walfrat Aug 22 '18 at 6:54
  • That is also possible... The message in question is on giving current weather conditions... I suppose I could send the temperature and specific things I care about in separate topics or something – Jeff Sep 12 '18 at 12:32
1

I'll propose an answer since it's been nearly a year.

As @Walfrat has pointed out:

Note that if you're echanging too much data, it might also be a design problem that would lead to poor performance in production environment (where the badwith and stability of the connection is not always here).

With that in mind, it might be better to push a more "notification-like" message in the websocket. A browser client could display this as an alert or badge, and a server-client (a server subscriber) could take this as a trigger to then query the RESTful endpoint. So, essentially:

  1. Server pushes a "we have new data in this channel" message.
  2. Client receives the message, and based on the small amount of info passed, knows which api endpoint to query to get a more full response.

This allows for a near instant knowledge of new data, and using a RESTful endpoint as designed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.