WebSocket Does Not Reconnect When App Resumes from Background (Guest User)
masarusanjp opened this issue · 4 comments
What did you do?
I launched the app, waited for a few minutes, and then resumed it.
What did you expect to happen?
I expected the WebSocket to reconnect when the app resumes from the background.
What happened instead?
The WebSocket does not reconnect when the app resumes from the background.
GetStream Environment
GetStream Chat version: 4.60.0
GetStream Chat frameworks: StreamChat, StreamChatUI
iOS version: iOS17.4
Swift version: 5.9
Xcode version: 15.3
Device: Simulator iPhone 15 Pro
Additional context
Reproduce Step
- launch DemoApp
- Tap
Guest User
- Suspend app
- Waiting for few minutes
- Resume app
- Tap
Start a chat
Screencast
https://drive.google.com/file/d/1-parw6tuS02VBZW7cG3__1Pb4e3ciogL/view?usp=sharing
(Here is a link to GoogleDrive due to its large size)
Additional Information
I discovered that the connectGuestUser function calls logOut first. As a result, ConnectionRecoveryHandler.stop is invoked, causing the monitoring of appDidBecomeActive and appDidEnterBackground to stop. This leads to the issue where "the WebSocket does not reconnect when the app resumes from the background.
This issue reliably reproduces with a guest user, but it is likely to occur under any condition where logOutFirst is true.
Hi @masarusanjp, thanks for spotting this issue!
The actual issue is that when reconnecting, logOut should not be happening, so the logic should be changed here. Stopping the recovery handler on logout is something that we want, but it caused this unwanted side effect due to the fact that logOutFirst in guest user is not properly implemented it seems.
We will pan this fix, and we will let you know once we start working on it. At the moment we do not have an ETA on when this will be fixed.
Best,
Nuno