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

Channel history problem #717

Closed
ova-adam opened this issue Apr 24, 2018 · 6 comments
Closed

Channel history problem #717

ova-adam opened this issue Apr 24, 2018 · 6 comments
Assignees

Comments

@ova-adam
Copy link

Our code throws an error when trying to load history once the iOS device is disconnected for longer than 2 minutes.

Log:
--Here we set the device to Airplane mode

2018-04-23 17:50:06.528305-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 57, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:50:20.647730-0400 O-Valet Handheld[26742:4385743] ERROR: R:0x15d4d8f0 No activity seen from realtime in 25.526613 seconds; assuming connection has dropped

2018-04-23 17:50:20.652417-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 80003, message: Idle timer expired, reason: (null)

2018-04-23 17:50:37.152285-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:50:37.152530-0400 O-Valet Handheld[26742:4385986] [] nw_connection_get_connected_socket_block_invoke 8 Connection has no connected handler

2018-04-23 17:50:37.155429-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:50:53.659681-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:50:53.660322-0400 O-Valet Handheld[26742:4386017] [] nw_connection_get_connected_socket_block_invoke 9 Connection has no connected handler

2018-04-23 17:50:53.663506-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:51:10.168720-0400 O-Valet Handheld[26742:4385743] [] nw_connection_get_connected_socket_block_invoke 10 Connection has no connected handler

2018-04-23 17:51:10.168981-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:51:10.171386-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:51:26.453139-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:51:26.453264-0400 O-Valet Handheld[26742:4386061] [] nw_connection_get_connected_socket_block_invoke 11 Connection has no connected handler

2018-04-23 17:51:26.455298-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:51:42.902024-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:51:42.902845-0400 O-Valet Handheld[26742:4386113] [] nw_connection_get_connected_socket_block_invoke 12 Connection has no connected handler

2018-04-23 17:51:42.906283-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:51:59.387330-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:51:59.387653-0400 O-Valet Handheld[26742:4386088] [] nw_connection_get_connected_socket_block_invoke 13 Connection has no connected handler

2018-04-23 17:51:59.390861-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:52:15.885478-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:52:15.885921-0400 O-Valet Handheld[26742:4386143] [] nw_connection_get_connected_socket_block_invoke 14 Connection has no connected handler

2018-04-23 17:52:15.888495-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:52:32.397351-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:52:32.399495-0400 O-Valet Handheld[26742:4386227] [] nw_connection_get_connected_socket_block_invoke 15 Connection has no connected handler

2018-04-23 17:52:32.404633-0400 O-Valet Handheld[26742:4384951] Ably disconnected! ARTErrorInfo with code 50, message: NSPOSIXErrorDomain, reason: NSPOSIXErrorDomain

2018-04-23 17:52:34.706745-0400 O-Valet Handheld[26742:4384951] ARTOSReachability: instance not found for target <0037e615>

2018-04-23 17:52:35.655038-0400 O-Valet Handheld[26742:4384951] ARTOSReachability: instance not found for target <0037e615>

--3 messages are sent while the device is offline

--Here we disable Airplane mode and Ably automatically reconnects:

2018-04-23 17:52:48.887252-0400 O-Valet Handheld[26742:4384951] Ably connecting! (null)

2018-04-23 17:52:49.717793-0400 O-Valet Handheld[26742:4386191] WARN: R:0x15d4d8f0 ARTRealtime: connection has reconnected, but resume failed. Reattaching any attached channels

2018-04-23 17:52:49.721276-0400 O-Valet Handheld[26742:4384951] Ably connected!

2018-04-23 17:54:10.694405-0400 O-Valet Handheld[26742:4384951] ARTOSReachability: instance not found for target <0037e615>

How we set up the listener:

        NSString *ablyChannel = @"ov:sync-updates-sv1";

        ARTRealtimeChannel *channel = [sharedInstance.ablyClient.channels get:ablyChannel];

        NSLog(@"Ably channel: %@", ablyChannel);

        
        //working history which only gets the messages missed during a disconnect

        [channel attach:^(ARTErrorInfo *error) {

            ARTRealtimeHistoryQuery *query = [[ARTRealtimeHistoryQuery alloc] init];

            query.untilAttach = true;

            

            [channel history:query callback:^(ARTPaginatedResult<ARTMessage *> *resultPage, ARTErrorInfo *error) {

                NSLog(@"%lu messages received in first page", (unsigned long)[resultPage.items count]);

                

                NSLog(@"%@", resultPage.items);

                NSLog(@"%@", resultPage.items.firstObject);

                NSLog(@"%@", resultPage.items.firstObject.data); // payload for the message

                NSLog(@"%lu", (unsigned long)[resultPage.items count]); // number of messages in the current page of history

                

                

                if (resultPage.hasNext) {

                    [resultPage next:^(ARTPaginatedResult<ARTMessage *> *nextPage, ARTErrorInfo *error) {

                        // retrieved the next page in nextPage

                    }];

                }

            } error:nil];

        }];

This function above fires properly when the app is first launched and history is loaded, but throws the "WARN: R:0x15d4d8f0 ARTRealtime: connection has reconnected, but resume failed" if the device goes into airplane mode and out again.

This has worked in the past, so not sure what's going on. There isn't any documentation on the error message, either, so we're a bit lost here. It seems to only be recently because I've tried previous branches of our code that worked months ago and those have the same problem now too. Has there been changes to the backend at Ably or are we doing something wrong?

@funkyboy funkyboy self-assigned this Apr 24, 2018
@funkyboy
Copy link
Contributor

@ova-adam Thanks for reporting this. I'll investigate.

In the meantime you can set a more detailed log level (clientOptions.logLevel = ARTLogLevelDebug;) to have more data about what's going on.

A few questions:

  • which version of Ably SDK are you using?
  • on which iOS version is this happening?

@funkyboy
Copy link
Contributor

@ova-adam Also. One thing is not clear to me.
What do you mean by "Our code throws an error"? Is the app crashing?

@ova-adam
Copy link
Author

ova-adam commented Apr 24, 2018 via email

@mattheworiordan
Copy link
Member

it will not replay any missing history that took place.

I don't follow what you mean. If a device is not connected for 2 minutes, then a resume will fail (see https://www.ably.io/documentation/realtime/connection#connection-state-explained), and history will not be replayed automatically (which seems ot concur with your statement the warning "connection has reconnected, but resume failed").

Then as far as I can tell, in your logs we see:

2018-04-23 17:54:10.694405-0400 O-Valet Handheld[26742:4384951] ARTOSReachability: instance not found for target <0037e615>

Is this an Ably error?

What error are you seeing other than "connection has reconnected, but resume failed" which is expected when disconnected for a period of time.

@funkyboy
Copy link
Contributor

@ova-adam

but once I resume from airplane mode (say in 3
minutes), it will not replay any missing history that took place.

This is intended behavior. As @mattheworiordan mentioned, after you are disconnected for 2 minutes, a resume will fail.

You can use the history API to fetch further data back in history.

@funkyboy
Copy link
Contributor

funkyboy commented May 4, 2018

Closing this. Feel free to reopen if needed.

@funkyboy funkyboy closed this as completed May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants