web_socket_client icon indicating copy to clipboard operation
web_socket_client copied to clipboard

fix: Websocket not updating state connection

Open martinpelli opened this issue 5 months ago • 0 comments

Description

Hi, didn't know how to classify this, maybe is a bug, maybe a question or maybe a documentation problem.

I have an app that needs a behavior like Whatsapp or any messenger app, that when you open the app it should always update the screen if there is new data. So when using this websocket all is good while I am on the app. But when I go to another app or block the device for a long time, websocket of course loose connection maybe because of how Android or iOS handles background calls. So there are some times that websocket is not able to reconnect, I mean is not even noticing it (using the listener for state connection). Idk if this is a expected behavior when you leave the app? How I can handle this? I am helping me with WidgetsBindingObserver, but as I don't know if the websocket looses connection I don't have a way to know if a call to remote data source is needed. Another question that I couldn't find is the amount of time that strategies tries to reconnect, is infinite? I am using the default one.

This is happening only on a physical device, I am not able to reproduce it on emulator. No matter if I lock the device for hours, websocket state connection works great. But there is a second problem related: disabling wifi and enabling, happens in both, physical and emulator devices, the listener is not fired.

Expected Behavior listener should always communicate the state of the connection? How to handle when you go out of the app, and come back, listener should reconnect? If you disable internet connection like Wifi, and re enable it, webscoket should reconnect? Or at least communicate it on the listener?

martinpelli avatar Mar 14 '24 18:03 martinpelli