`Whoops! Lost connection to` error with npm

Author: iutxCreated Aug 16, 2024Updated Aug 16, 2024

Desc

I use

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

to connect websocket

javascript
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

xml
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sockjs.min.js"></script>
bash
const socket = new window.SockJS(url);

all things ok.

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