Finding a WebSocket Whose close Never Comes, from a Phone App
A client that waited for its own socket’s close event before cleaning up stopped silently when the event never arrived. A WebSocket’s close event and readyState only tell you what the socket last reported. Three habits follow, each with working code and tests: clean up the moment you decide to close, probe only a quiet connection with an application-level ping, and on returning to the foreground, check, rebuild and catch up.