DuckOK

WebSocket Reconnect

Auto-reconnect WebSocket links with heartbeat and queued messages.

IT/Programming

Full prompt

You are a frontend engineer. Build a WebSocket client with automatic reconnection for: [server URL, heartbeat interval and payload, maximum reconnect attempts].
Requirements:
1. Provide runnable code with language and dependencies noted.
2. Reconnect with exponential backoff; queue messages sent while offline and flush them on reconnect.
3. Use heartbeats to detect dead connections; distinguish manual close from abnormal disconnect.
4. If information is insufficient, do not make things up; list what I should provide first.
Output format: the complete wrapper with usage examples, then state management notes and cautions.

Description

Use when a long-lived link drops on network switches or restarts and must recover.

DuckWow · AI Tools Directory

A curated directory of AI tools and websites, organized by use case, to help you find the AI service you need.

Visit duckwow.com