Skip to main content

design-a-websocket-reconnection-strategy

Design WebSocket reconnection with state identity, backoff, resume tokens, replay, deduplication, ordering, authentication, and user feedback. Use when transient disconnects must not lose or duplicate live state.

Source facts

Repository
protosphinx/sphinxstack
Last source activity
July 29, 2026 at 13:55
Detected SKILL.md language
English
Stars
3
Forks
0

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

File Explorer
2 files

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
design-a-websocket-reconnection-strategy
category
code
description
Design WebSocket reconnection with state identity, backoff, resume tokens, replay, deduplication, ordering, authentication, and user feedback. Use when transient disconnects must not lose or duplicate live state.
# design-a-websocket-reconnection-strategy ## When to use - Use for chat, collaboration, dashboards, control, notifications, or streaming UI. - Do not automatically replay non-idempotent client commands. ## Preconditions - Define session, message, stream, authorization, ordering, retention, offline, and recovery semantics. ## Procedure 1. Assign connection, session, stream, message, and operation identities. 2. Distinguish transport connection from authenticated application session. 3. Use bounded exponential backoff with jitter and online or visibility signals. 4. Resume from an acknowledged sequence or request a snapshot plus delta. 5. Deduplicate operations and reject stale session or authorization epochs. 6. Surface disconnected, reconnecting, stale, and recovered states accessibly. 7. Test partition, deploy, token expiry, missed retention, duplicate, reorder, and server restart. ## Failure plan - Fall back to a fresh authorized snapshot when safe resume cannot be proven. ## Worked example A collaborative editor restores from the last acknowledged operation and rejects a duplicated edit after reconnect. ## Done - A reconnection design document records identity, backoff, resume, snapshot, replay, auth, UI state, and observability - Partition, duplicate, reorder, token, retention, deploy, restart, offline, and stale-session tests verify recovery
View on GitHub