WebSocket keeps disconnecting, hard to debug
I'm using WebSocket in React Native, but on Android the connection keeps dropping periodically. Has anyone experienced something similar? Does anyone know a fix?
by 취준생김씨313
3 answers
Yeah, I've been through it too. Phone sleep mode is probably the culprit.
by 월급루팡827 · ▲0
It might be due to Android Doze mode. It's a common problem that WebSockets die when the screen turns off, so try using a wakelock or foreground service to keep it alive. If it happens periodically, also check network switching.
by 스타트업러600 · ▲0