Skip to content
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

Connect whilst suspended does not appear to be connecting immediately #167

Closed
mattheworiordan opened this issue Sep 29, 2016 · 1 comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@mattheworiordan
Copy link
Member

This from a customer:


I enter aeroplane mode. The connection is lost, eventually, the connection type changes to suspended and the channels detach. All good.

The logs read:

09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: failQueuedMessages() 
09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: failQueuedMessages() 
09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: setSuspended(); channel = public:30UYA0755 
09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: setState(): channel = public:30UYA0755; setting detached 
09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: failQueuedMessages() 
09-29 13:25:13.402 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: failQueuedMessages() 
09-29 13:25:13.407 12566-12566/com.rundosrun.groupchat I/groupChat: Connection state changed. State: suspended

At this point, I show a "retry" button on the screen.

In my testing, I now come out of aeroplane mode and wait a few seconds to ensure there is a good connection to WiFi/4G.

I tap the retry button which calls the following code:

mAblyRealtimeClient.connection.connect();

You can see the time of this in the log under "WILL TRY TO RECONNECT NOW"

At this point, absolutely no ably logs are generated, so the ably client is doing nothing at all, even though I called connect.

Nearly 2 full minutes later, it attempts to connect, and does so:

09-29 13:25:13.407 12566-12566/com.rundosrun.groupchat I/groupChat: Connection state changed. State: suspended 
09-29 13:25:24.867 12566-12566/com.rundosrun.groupchat E/groupChat: WILL TRY TO RECONNECT NOW 
09-29 13:27:13.403 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: requestState(): requesting connecting; id =XXXXX 
09-29 13:27:13.404 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: notifyState(): notifying connecting; id = XXXXX
09-29 13:27:13.405 12566-12647/com.rundosrun.groupchat I/System.out: (INFO): TokenAuth.authorise(): 
09-29 13:27:13.405 12566-12647/com.rundosrun.groupchat I/System.out: (INFO): TokenAuth.authorise(): using cached token; expires = 1475154843153 
09-29 13:27:13.406 12566-12647/com.rundosrun.groupchat I/System.out: (INFO): TokenAuth.getTokenDetails(): 
09-29 13:27:13.407 12566-12647/com.rundosrun.groupchat I/System.out: (DEBUG): io.ably.lib.transport.ITransport: getConnectParams: params = [access_token:RCx6fQ.DBlvTxTtRdTyfVY-2MLptE-Is1NZFvaFP7nfaWtOG-p_haDC_TV_EsC_F3Q5qem1ChtxJ3GBbogRvtFLw_Zni2rOuHMCWkyWz9aTHUlB_VPhwmH5SxPfs_WFI_c_LhWV9, format:msgpack, resume:XXXX, connection_serial:-1, client_id:steven] 
09-29 13:27:13.449 12566-12647/com.rundosrun.groupchat I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: setState(): setting connecting 
09-29 13:27:13.450 12566-12647/com.rundosrun.groupchat I/groupChat-Singleton: New state is connecting
@mattheworiordan mattheworiordan added the bug Something isn't working. It's clear that this does need to be fixed. label Sep 29, 2016
trenouf pushed a commit that referenced this issue Oct 4, 2016
#167
says that, after a disconnect caused by a network outage, then waiting
long enough for the connection to go disconnected state and the channels
to be detached, an explicit AblyRealtime.connection.connect() is not
immediately actioned. Instead it does not connect until up to a couple
of minutes later.

It looks like the condition is incorrect in ConnectionManager.connect()
to see if a connection attempt is already underway, so the explicit
connect does not do anything. Instead it waits until the next time it
would have attempted a reconnect anyway.

Fixed.

Also fixed so that the connect happens even if there is a connection
thread already started.
trenouf pushed a commit that referenced this issue Oct 4, 2016
trenouf pushed a commit that referenced this issue Oct 4, 2016
@trenouf
Copy link
Contributor

trenouf commented Oct 5, 2016

Fixed by
#172

@trenouf trenouf closed this as completed Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

2 participants