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

React Native Integration : Duplicate connection when the app is in background then reopen #168

Open remibed opened 4 years ago

remibed commented 4 years ago

Hi,

First, thank you for your usefull library.

By the way, we are facing to a several issue using it in our React Native Application.

To reproduce, we just have to put our application in background, then to reopen it 1 minute after. Then put it in background again and re open it 1 minute after. (you can do it how many time you want :D)

In this case, we can see that the more you restart your app, the more you will have connection and topic subscribed. (exactly the same problem than here )

At the beginning, I though it was the stomp.js fault, that trigger too much connect event, but maybe it is in the react-stomp connect handler that initiate a new stomp client (this.initStompClient()) on each _connect event.

We just fixed this issue by now using a very large heartbeat property (yeah, it's dirty), so no hurry, but I think this bug should be fixed.

(I can try to test and make a PR in the next few days if I got time)

Thank you.

lahsivjar commented 4 years ago

Hi @remibed,

Thanks for the report. I will look into this.

nctay commented 4 years ago

Hi @remibed ! Have you came up with any fix of this problem?

remibed commented 4 years ago

Hi @nctay,

No we don't... As I explained we're on a production rush so we have opted for the dirty solution "large heartbeat" for now... But now we're not so sure that's an issue with the initStompClient, we think it's more about session reconnection.

@lahsivjar did you reproduce the issue ?

nctay commented 4 years ago

@remibed @lahsivjar Can it be some browser issues? Seems like chrome is trying to kill connection, but client keeps reconnecting.

remibed commented 4 years ago

sorry @nctay has I explain my issue is in ReactJS, so I don't make a direct relation with Chrome in my case.

bhawad commented 3 years ago

Hello,

This also happens with me with ReactJs , when the tab stays in-active for several minutes it begins to replicate the connection till it gets hundreds of connections to my server. Is there any advisable solution to this?

remibed commented 3 years ago

@bhawad I did not find anything last year :) The dirty solution by now was to set a very large heartbeat property. (I did not spend too much time on this thing since I reported it)

mixtoism commented 1 year ago

Still no updates?