-
Notifications
You must be signed in to change notification settings - Fork 199
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
Amplify.API.subscribe can not be connected to server in the first time launch app #3831
Comments
Thanks for opening the issue. Our team will look into the issue and provide update. |
@harsh62 |
Hi @santoso8118, do you have any verbose logs we can investigate to see what is happening? Do you have |
Thanks @lawmicha |
Hi @lawmicha
|
@lawmicha The app sync subscription is unable to recover after it disconnects when app is in background. Even after upgrading to 2.37.0 we still see the error. However now we receive the following error in addition in log in 2.37.0: Amplify.APIError error 3. |
Hi @AnirudhWinimy / @santoso8118 , from my understanding, the changes made by @5d (please chime in if I'm wrong here) in #3800 for #3632 released in 2.37.0 will propagate the connection lost error back to the caller. The APIError has an error description, recovery suggestion, and optional underlying error. In the PR, we are returning APIError.networkError with an underlying error of |
Hi @lawmicha : When the error happens we try to perform subscription again its always got failed with the same error. By the way could you tell me how long subscription get timeout if can not connect to server ? |
To elaborate further, your suggestion works when we downgrade to version 2.28.0, i.e we can re-subscribe when the app is back to the foreground. However since upgrading to 2.33.3 (and even on 2.37.0) whenever the app goes to the background and returns to the foreground, calling re-subscribe consistently fails with a network timeout error almost immediately. In reality there is no connection error and any mutations sent works. The error lines when attempting to re-subscribe are shared in
|
Hi @santoso8118 According to the log, the websocket encountered a kernel-level error: kNWErrorDomainPOSIX with code 53, indicating "Software caused connection abort." This error typically occurs when the application is moved to the background. The subscription timeout error happens 5 seconds after the request is sent, which is expected behavior since we’ve set a default 5-second timeout for a connected websocket to receive a response from the server. To better understand the complete testing scenario, could you provide the full log from when you reproduce this issue? This additional information would help us gain a more comprehensive view of the problem and its context. ref: |
Hi @lawmicha We already share all the logs that we have after enable the verbose log and reproduce the issue. I see that there are some release versions recently that fixed issues relate to appsync and web socket connection. |
Hi @santoso8118, We are currently trying to replicate the behavior on our latest version and will get back to you once we have an answer. Thank you for the log provided here and the code example with support. |
So I spend considerable time trying to reproduce the issue and was unable to see the subscription error reported. I have tried on both the latest version of Amplify and also on the affected version (2.33.3) in the ticket. Amplify behaves consistently every time.
I have followed the Amplify documentation guide to setup a simple app to reproduce the issue in an isolated environment. My subscription code is exactly the same mentioned in the documentation and I am using the following strategy to test backgrounding and foregrounding the app.
Just so that everybody is on the same page, following is my view models subscription and cancellation calls.
App verbose Logs that I have observed during my debugging session
As of next steps, I would suggest that try to reproduce the issue in a local isolated environment and share that with the team otherwise its very difficult to further investigate the issue. |
We recently migrated from AWS AppSync SDK for iOS to aws amplify sdk as per the deprecation notice (https://github.com/awslabs/aws-mobile-appsync-sdk-ios) In the official aws notification for us to migrate we were provided the following link to upgrade which we are following We are using a similar mechanism to subscribe shared in the link above
The above works for the first time launch and the re-subscribe from background to foreground works in 2.28.0 using the above mechanism. However after upgrading above 2.28.0 this mechanism stops working. |
Hi @AnirudhWinimy, Using the latest version of Amplify, can you please attempt to create a sample app demonstrating the bug that you are experiencing and we could pull that app down and test? As @harsh62 mentioned, we have been unable to reproduce the reported bug that is being described. |
We now suspect the issue was caused due to a forceful disconnection to the appsync websocket connection that was initiated by the os, when the app moved to the background. This (app connections termination in background) is something that we observed and seems to be valid scenario as per the ios documentation. This was observed when testing on multiple devices on builds using Xcode 15.2 targeting ios 16.2 . However after upgrading the xcode and ios version to version 18, we are unable to reproduce even the forceful connection disconnection event triggered by the os in the background. And thereby unable to reproduce this issue in the affected amplify sdk versions ( i.e versions above 2.28.0) in ios 18. Our next step is to try to rollback our version to match the original environment and see if we can reproduce the issue. |
Thank you for the status update. If you discover anything, please let us know. |
Describe the bug
When user login to our app
We config Amplify with below configurations:
In the first time install app and open app then login successfully then we call Amplify.API.subscribe to our subscription but I only got failed connection and we can not receive any datas from server, the states as below:
As normal connection states should be as below:
The issue only happen for the first time subcribe. In the second time we successfully connect and get data
After relaunch the app and we try Amplify.API.subscribe again, all subscriptions are working fine.
Steps To Reproduce
Expected behavior
Amplify.API.subscribe should always connect successfully even the very first time
Amplify Framework Version
2.33.3
Amplify Categories
API
Dependency manager
Swift PM
Swift version
5.10
CLI version
12.12.4
Xcode version
15.2
Relevant log output
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 16.2
Device
iPhone 11
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: