-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pusher Reconnection issue #197
Comments
Actually maybe its the same as this guys problem: |
Also I think this calling this code over and over again is causing my connections to build up. Need to figure out a better way to make sure pusher stays connected. |
Hi @Salim1993 I built a test app that just tries to connect to one of our clusters making use of this library. I blocked my machine from being able to talk to this cluster via the hosts file. After starting the app, I watched the reconnection attempts build up.
As we can see here, we attempt to connect numerous times before giving up and moving to the DISCONNECTED state. Next, I added some code to the onConnectionStateChange handler, which will be triggered when the connection state changes to DISCONNECTED. This code will call pusher.connect() once the state moves to disconnected - in effect making this retry loop permanent. I left it running for around half hour, at which point we were still (unsurprisingly) attempting to reconnect. I've noticed two issues though.
Let me know if you've noticed anything else, I'm actively investigating this today. |
Hi, I've just discovered that we already support configuring the reconnection attempts! I am going to document this in the README to make it more obvious, but for now, on your PusherOptions object, call these two methods. setMaxReconnectionAttempts() sets the maximum number of attempts a given connection will be retried. There is a bug in the library relating to reconnection logic which means it only works once. I have addressed this in this PR: #201 and added more documentation in this PR: #202 I will try to get these merged in asap. Once again, thanks for your report. |
@kn100 Thank for the info. Let me know when the merge happens as I would be glad to check it out. Also I believe that my problem has happened a lot less by upgrading to latest version of pusher library. Still I would like to see the new merge changes as it would allow for more stability in my app. |
What is the issue?
Pusher will no longer reconnect after long periods of time. Will stay disconnected even after listening to the status change and calling pusher reconnect. Not to sure what to do at this point since we need pusher to be reliable for long periods of hours, for lets say 8 hours. From what I've read in the tickets, it seems like that there is max retry for pusher that will stop trying to connect after 6 attempts. Is this true and is maybe whats causing my issues? Any solutions or tips would be greatly appreciated.
This is the code that I sure to to listen to disconnect statuses, and then reconnect.
https://gist.github.com/Salim1993/acd765e1049bf0a74293a2798c850492
I had to use Gist because I couldn't get the code formatting to work properly. Let me know if you can't access the gist.
Is it a crash report? Submit stack traces or anything that you think would help
Not a crash,just pusher stops responding to events after a while. After looking at the psuher dashboard for events for a long time, i realized that pusher socket disconnects, but never reconnects again.
...
CC @pusher/mobile
The text was updated successfully, but these errors were encountered: