stompjs icon indicating copy to clipboard operation
stompjs copied to clipboard

websockets messages are NOT receiving after some time | ReactJS and springboot application

Open sachinpatil2 opened this issue 7 months ago • 4 comments

Please help me with any workaround for this problem.

It appears that the web sockets are not being received after a certain period of time. I have established a websocket connection using STOMPJS in a ReactJS application alongside a Spring Boot backend.

For reference, I have followed the setup instructions provided in the following link: https://spring.io/guides/gs/messaging-stomp-websocket.

I would greatly appreciate any assistance or workarounds you can offer to resolve this problem. Thank you!

sachinpatil2 avatar Jun 11 '25 06:06 sachinpatil2

@kum-deepak Please help on this.

sachinpatil2 avatar Jun 11 '25 13:06 sachinpatil2

I do not use Spring or React Native, so I am unable to provide specific guidance. The STOMP supports Heartbeats, both client-initiated and broker-initiated. These help the connection remain alive even during inactivity.

Please see https://stomp-js.github.io/guide/stompjs/using-stompjs-v5.html#heart-beating to enable it on the client side. Please check the Spring documentation on how to add support on the server side.

Once you implement the heartbeating, the client will disconnect and reconnect if the connection goes stale (i.e., it is no longer valid).

kum-deepak avatar Jun 11 '25 22:06 kum-deepak

@kum-deepak Thanks for your answer! Heartbeats are by default enabled both the side front and backside. I am not sure this issues happens due to heartbeat. Also I observed - If I opened multiples tabs with same session, then sometimes client won't receive messages in either tab or both tab. I noticed this issue frequently.

Is there am I missing anything on my end? I have setup heartbeat also both on frontend and backend side but still messages are not guaranteed to receive ALL TIME.

Please throw some light on this.

sachinpatil2 avatar Jun 13 '25 15:06 sachinpatil2

i got same issues. Any solution

kbqdev avatar Aug 15 '25 08:08 kbqdev