lahsivjar / react-stomp

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

Unable to disconnect if React Component is unmounted before ref=(client)=> async call #139

Open dsmingtsoi opened 4 years ago

dsmingtsoi commented 4 years ago

Hi

I am facing an issue while trying to disconnect the webstocket connection after render call and then unmounted immediately.

base on your example, I created a component to bring up the web socket connection when render call, however if the user click on something immediately after that and then unmounted, client ref may not be passed successfully while the connection could be up and running in background. On this case i found that we got some active web socket session in the background and keep receiving message

Any suggestion?

Thanks Ming

DIVANSHMAHAJAN commented 2 years ago

Did u find any solution for this problem . I am also facing the same problem as a result of which multiple notifications are coming after I click on something else and return back .

matinfo commented 2 years ago

I have same problem. Each time for example I click on a form the websocket connection is disconnected and reconnected immediately. Same each time I switch to an other page in my application.

result intempestive disconnection/reconnection and lot of : Stomp WebSocket Error in the console.

Notice: I need to inject bearer token in header, result the context is placed not at top in index.js, but just after in App.js to be able to get authentication access_token.

lucasrodrigues19 commented 2 years ago

I'm experiencing the same issue, when opening a connection socket and disassembling the component, after trying to connect again, the previous connection is still in the background.