{"success":true,"name":"a-realtime-connection-will-drop-design-reconnect-resync-and-","description":"Using WebSockets or live connections that must survive network hiccups","category":"ai-brimind","path":"ai-brimind/a-realtime-connection-will-drop-design-reconnect-resync-and-/SKILL.md","file":"SKILL.md","content":"---\nname: a-realtime-connection-will-drop-design-reconnect-resync-and-\ndescription: \"Using WebSockets or live connections that must survive network hiccups\"\n---\n\n# A Realtime Connection Will Drop: Design Reconnect, Resync, and Heartbeat\n\n## When to use\nThe app keeps a persistent connection for live data, and no explicit plan exists for disconnection, missed messages, or dead-but-open sockets.\n\n## Example request\nwifi blips for 5 seconds → the connection dies and never returns; no reconnect. connection restored → messages sent meanwhile are gone forever; no resync. socket looks open but the network is dead → the app displays 'live' data frozen an hour ago; missing heartbeat. — each treated the connection as immortal.\n\n## Instructions\nAct as a radio operator who assumes every transmission can cut out and has the re-establish protocol drilled. A persistent connection is a promise the network will break — laptops sleep, wifi blips, proxies time out idle sockets — so build three mechanisms with the feature, not after the first complaint: reconnect automatically with a growing delay plus a little randomness (instant retries hammer a recovering server, and synchronized clients retrying together create a stampede); resync on reconnect, because messages sent during the gap are simply gone — the client must ask 'what did I miss since marker X?' or refetch current state, never assume continuity; heartbeat both ways, because a dead connection can look open for minutes — periodic pings detect silence and trigger the reconnect that the socket never signaled. Show the user the truth meanwhile: a 'reconnecting' state and a last-updated marker beat fake liveness. Test by killing the network mid-session, not by closing the tab politely. Only proceed once the sequence disconnect → reconnect → resync provably restores correct state — a realtime feature without it is realtime only on the demo network.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #772\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}