WebSockets Can Stall Without Disconnecting — And It’s Worse on Android
While building a real-time messaging system, I ran into something frustrating: The WebSocket shows “connected”… but nothing works. No errors. No disconnect event. No messages going through. Just a ...

Source: DEV Community
While building a real-time messaging system, I ran into something frustrating: The WebSocket shows “connected”… but nothing works. No errors. No disconnect event. No messages going through. Just a connection that looks alive — but is effectively dead. The Problem On Android (especially Chrome and background scenarios), WebSockets can silently stall when: Network switches (WiFi → Mobile) App goes into background Device enters power-saving mode The connection stays OPEN, but: messages don’t send no events are received no onclose or onerror fires From the UI → everything looks fine From reality → it’s broken What “Connected” Actually Means WebSockets only tell you: “The connection is open” They don’t guarantee: “The connection is still usable” Here’s a typical example — the socket is technically connected: But this state alone doesn’t tell you if data is actually flowing. What Doesn’t Fix It A common approach is: “If the same user reconnects, replace the old socket” That helps with duplic