lahsivjar / react-stomp

React websocket component for STOMP protocol over SockJs
https://www.npmjs.com/package/react-stomp
MIT License
134 stars 41 forks source link

Why does an error occur if kept in the background ? #204

Open DIVANSHMAHAJAN opened 2 years ago

DIVANSHMAHAJAN commented 2 years ago

I am using react-stomp and stompjs and sockjs-client. However when the application is in background or not being used..and some other window is open.. It shows error after some time. **const onError = (err) => { window.alert("YES");

};** this line gets executed and shows YES ..plz tell me how to rectify this error.?

const connect = () => { const Stomp = require("stompjs"); var SockJS = require("sockjs-client"); SockJS = new SockJS("https://chat-lg.azurewebsites.net/ws"); stompClient=Stomp.over(SockJS); stompClient.connect({}, onConnected, onError); };

const onConnected = () => { stompClient.subscribe( "/user/" + currentUser.username + "/queue/messages", onMessageReceived ); };

const onError = (err) => { window.alert("YES");

};