sockjs / sockjs-client

WebSocket emulation - Javascript client
MIT License
8.45k stars 1.3k forks source link

`Whoops! Lost connection to` error with npm #658

Open iutx opened 3 months ago

iutx commented 3 months ago

Desc

I use

"sockjs-client": "^1.5.1",
"stompjs": "^2.3.3",

to connect websocket

const socket = new SockJS(url);
stompClient = Stomp.over(socket);

stompClient.connect({}, (frame) => {
  console.log('Connected: ' + frame);

  stompClient.subscribe(`/topic/${databaseName}/public`, (messageOutput) => {
    const message = JSON.parse(messageOutput.body);
    console.log(message);
    showMessage(message.sender + ':' + message.content);
  });
});

that throw Whoops! Lost connection to error.

But i import same version "sockjs-client": "^1.5.1" with mini.js

<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1.5.0/dist/sockjs.min.js"></script>
const socket = new window.SockJS(url);

all things ok.

It's very confusing to me. What is the direction of troubleshooting, thanks!