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

WebSocket Does Not Reconnect When App Resumes from Background (Guest User) #3338

Open
masarusanjp opened this issue Jul 28, 2024 · 3 comments
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK

Comments

@masarusanjp
Copy link

masarusanjp commented Jul 28, 2024

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.

https://github.com/GetStream/stream-chat-swift/pull/3303/files#diff-5aa17a3514ab85c33231ca8983e4c32096742c79d97924fe31e71ebb0ac7d540R385

This issue reliably reproduces with a guest user, but it is likely to occur under any condition where logOutFirst is true.

@nuno-vieira nuno-vieira changed the title WebSocket Does Not Reconnect When App Resumes from Background WebSocket Does Not Reconnect When App Resumes from Background (Guest User) Jul 28, 2024
@nuno-vieira
Copy link
Member

nuno-vieira commented Jul 28, 2024

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

@nuno-vieira nuno-vieira added 🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK labels Jul 28, 2024
@98prabowo
Copy link

Hi @nuno-vieira, does this only affect guest user? or all user?

@nuno-vieira
Copy link
Member

Hi @nuno-vieira, does this only affect guest user? or all user?

Hello! Only guest and anonymous user yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 Bug An issue or PR related to a bug 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

No branches or pull requests

3 participants