Open james04gr opened 3 years ago
Hello @james04gr, did you manage to figure out how to resolve this? I am facing a similar issue on a project I am working on.
No...try to find another library! The guy that has this never answers!
I have the same issue, has anyone figured out a solution?
I have the same issue, has anyone figured out a solution?
The solution is to switch to another library. Nobody takes care of this one
has this issue been fixed
after connect and disconnect to websocket, OnConnectionOpened triggered 1 more time: D/rere: WebSocket.Event.OnConnectionOpened D/rere: WebSocket.Event.OnConnectionOpened D/rere: WebSocket.Event.OnConnectionOpened D/rere: WebSocket.Event.OnConnectionOpened
TL;DR - Ensure you call disconnect on each LifecycleRegistry
object used to open the socket.
If you are listening to the lifecycle state using things classes like AndroidLifecycle.ofApplicationForeground
, be careful you instantiate only a single instance per application.
Faced a similar issue and the lifecycle is tied to the application's lifecycle so it can cause the socket to reconnect even when you did not intend it to. To mitigate this, ensure the call to disconnect is called from all the LifecycleRegistry
object used to open the socket.
By using Koin i create my networkModule like below
I also have an Observer class that is registered to the Application lifecycle.
which of course is initialized in the Application class
When the app starts, Scarlet creates a connection and onEnterForeground is triggered. So the LiveData outputs
OnConnectionOpened(webSocket=okhttp3.internal.ws.RealWebSocket@6795837)
After that i press the home button so the application enters background, so the Scarlet has to cancel the current socket connection. However after relaunch the app, app gets in Foreground start, Scarlet has to reopen the connection as it does but the problem is that in my Logcat i see double times the print
And as i go on and do the same thing the onConnectionOpened gets multiplied...!! What is going wrong??