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

AWS Amplify SDK IOS - Subscription When App Remains Idle for a Long Time Oflline #409

Closed
Dachmian opened this issue Sep 1, 2020 · 2 comments
Labels
question A question about how to use an existing feature requesting info Further information is needed before this is actionable

Comments

@Dachmian
Copy link

Dachmian commented Sep 1, 2020

Describe the bug
When app is in background for a long time > 10 min without network connection, the subscriptions are not restarted.

To Reproduce
Steps to reproduce the behavior:
This is a very similar issue to: #396 except that I disabled network connection while app is in background by disabling WiFi while in background and then enabling WiFi right before I open the app again. If app is in background < 10 min without network connection this issue does not occur.

So to reproduce:

  1. Start App and initialise a subscription to GraphQL via subscribe(subscription:queue:statusChangeHandler:resultHandler).

  2. Make sure subscription is connected.

  3. Send app to background.

  4. Disable network by turning WiFi off.

  5. Wait a rather long period of time (>10 minutes).

  6. Enable WiFi.

  7. Activate app again and try to create a new subscription from applicationWillEnterForeground.

The following logs are produced:

2020-09-01 16:31:02.265291+0200 WebsocketDidReceiveMessage - {"id":"7BDF24BF-D324-4543-806E-A7D61CC7D5B2","type":"start_ack"}
2020-09-01 16:31:02.265475+0200  Resetting stale connection timer
2020-09-01 16:31:02.265561+0200  Self is nil, listener is not called.

It seems to be hitting the following condition:

AppSyncLogger.debug("Self is nil, listener is not called.")

in AppSyncSubscriptionConnection.

I managed to work around this solution by manually disposing the subscriptions when app goes to background and then re-subscribing when app goes to foreground again but it was to my understanding that background/foreground and offline/online should be handled by the SDK itself?

Expected behavior
To be able to create new subscriptions.

Screenshots

Environment(please complete the following information):

  • AppSync SDK Version: 3.1.5
  • Dependency Manager: Cocoapods
  • Swift Version : 5.0

Device Information (please complete the following information):

  • Device: iPhone11
  • iOS Version: 13.6
  • Specific to simulators:

Additional context
Add any other context about the problem here.

@palpatim
Copy link
Contributor

palpatim commented Sep 2, 2020

@Dachmian

I managed to work around this solution by manually disposing the subscriptions when app goes to background and then re-subscribing when app goes to foreground again but it was to my understanding that background/foreground and offline/online should be handled by the SDK itself?

That is only the case if you use AppSync's Delta Sync functionality.

@palpatim palpatim added AppSync question A question about how to use an existing feature requesting info Further information is needed before this is actionable labels Sep 2, 2020
@Dachmian
Copy link
Author

Dachmian commented Sep 2, 2020

@palpatim Ok, thank you for clarification.

So if subscriptions are not cancelled when app goes to background then it is not possible to create new subscriptions afterwards if the described conditions are met.

I will close this but you can reopen if this is something you will investigate/fix.

@Dachmian Dachmian closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about how to use an existing feature requesting info Further information is needed before this is actionable
Projects
None yet
Development

No branches or pull requests

2 participants