react-stomp icon indicating copy to clipboard operation
react-stomp copied to clipboard

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

Open remibed opened this issue 4 years ago • 8 comments

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.

remibed avatar Aug 18 '20 13:08 remibed

Hi @remibed,

Thanks for the report. I will look into this.

lahsivjar avatar Aug 21 '20 10:08 lahsivjar

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

nctay avatar Oct 01 '20 08:10 nctay

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 ?

remibed avatar Oct 01 '20 08:10 remibed

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

nctay avatar Oct 01 '20 19:10 nctay

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

remibed avatar Oct 30 '20 15:10 remibed

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?

bhawad avatar May 19 '21 11:05 bhawad

@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)

remibed avatar May 19 '21 14:05 remibed

Still no updates?

mixtoism avatar Oct 17 '23 14:10 mixtoism