-
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 doesn't reconnect when network is disconnected for ~5 min #210
Comments
I'm concerned that PusherOptions options = new PusherOptions().setMaxReconnectionAttempts(1000000);
Pusher pusher = new Pusher(YOUR_APP_KEY, options); |
The reconnection logic might not working for total network break-down beyond 60 seconds, and some special conditions. CauseSetting max reconnection attempts along max reconnection gap works, though: PusherOptions options = new PusherOptions()
.setCluster("eu")
.setMaxReconnectionAttempts(Integer.MAX_VALUE)
.setMaxReconnectGapInSeconds(30)
; Nevertheless reconnecting fails after network is gone for 60 seconds, because the DNS TTL turned the host name IP resolution invalid, leading to an exception, making the Pusher websocket handler bail out. An Pusher exception occured: An exception was thrown by the websocket [null]
java.net.UnknownHostException: ws-eu.pusher.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:606)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:666)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:395)
at java.lang.Thread.run(Thread.java:748) This is, what DNS is giving me at this moment for the hostname ws-eu.pusher.com.
Although the CNAME value for the host is valid for 3600 seconds (checked the max value by querying Amazon DNS directly!), the CNAME targets are only valid for 60 seconds. So after 60 seconds, no IP address can be resolved and Pusher websocket handler fails with the mentioned exception. MitigationSometimes, Pusher library continued to try reconnection, sometimes it did not, which i need to continue investigating. What I did in my code, was, to add a connection listener, handling this special case. Upon first successful connection, a flag will indicate that the host name is valid in principle. If an |
Would love to see this mitigation built directly into the library. |
Having an issue that might be the same in my app : |
Pusher doesn't reconnect when network is disconnected for ~5 min.
Steps to reproduce:
Connect to Pusher and subscribe to channel. Events are received as usual.
Turn off Wifi for ~5 min.
Turn on Wifi.
What I can observe is that there is a Disconnection message in the web console once Wifi is turned on, but in the app, pusher.connection.connectionState still returns connected and pusher.connection.socketId returns the disconnected(as seen in the web console) socket id.
It works fine if Wifi is turned off for less than 2-3 min - it auto reconnects and receives events again, it's only an issue when it's disconnected for ~5 min or more.
I've also added
but it doesn't change anything.
I've also added a listener on changedConnectionState, but the only time it fires is during the initial connection setup - it goes from connecting to connected.
The text was updated successfully, but these errors were encountered: