Closed francoisgelinas1 closed 1 year ago
This appears to be an issue in Safari since iOS 15 (https://developer.apple.com/forums/thread/685403).
The behavior of Safari websockets changed with the introduction of experimental feature "NSURLSession WebSocket".
You can see a similar failure with this test page https://libwebsockets.org/testserver/. Follow the same reproduction steps by placing Safari in the background for a few seconds then see that the websocket disconnected.
It is possible to disable this experimental feature on a per device basis, and the websockets will function as expected.
That doesn't really help your users though (unless they all disable the feature), but it would help pin down the root cause. If you have the time could you confirm disabling this feature fixes the issue on your app?
We'll look to see if there is a fix on our end to bypass the bug.
Thank's for your response!
It fixed the problem after i disabled the feature and restarted the iPhone.
Even if there is a workaround, do you thing it would be possible to catch the error of the websocket and sync again the Datastore?
Yes, some sort of reconnect logic on the error will probably be the fix.
JavaScript Framework
Angular
Amplify APIs
DataStore
Amplify Categories
api
Environment information
Describe the bug
When Safari IOS is in background, the websocket is closed and Datastore stops listening to changes. When you open Safari again, you get this error:
WebSocket connection to 'wss://anshee6pbze3lptwgjfeem7aw4.appsync-realtime-api.ca-central-1.amazonaws.com/graphql?header=[...]' failed: The operation couldn’t be completed. (kNWErrorDomainPOSIX error 53 - Software caused connection abort)
The Datastore was not synced during the time Safari was in background.
Expected behavior
Sync the datastore after websocket failed
Reproduction steps
Mobile Device
Iphone
Mobile Operating System
16.3.1
Mobile Browser
Safari
Mobile Browser Version
16.3
Additional information and screenshots
No response