79768780

Date: 2025-09-18 17:51:54
Score: 1
Natty:
Report link

Each attempt to connect needs a new socket. So, your code:

      const socket = new SockJS('http://localhost:8080/ws');
      console.log("socket -> ", socket);
      const stompClient = new Client({
          webSocketFactory: () => socket,

Needs to change to

      const stompClient = new Client({
          webSocketFactory: () => new SockJS('http://localhost:8080/ws'),

Basically, the factory method must return a new socket when invoked.

See https://stomp-js.github.io/guide/stompjs/rx-stomp/using-stomp-with-sockjs.html

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Deepak Kumar