WebSocket Reconnect for Openclaw

A sophisticated WebSocket management tool providing automated recovery through exponential backoff, jittered retries, and circuit breaker patterns.

qwe123sddfsdfs
v1.0.0
Mar 4, 2026
0
863
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install websocket-reconnect

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install websocket-reconnect using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is WebSocket Reconnect?

The WebSocket Reconnect skill is a professional-grade connection manager designed to handle the complexities of real-time communication in distributed environments. It solves the problem of unstable network connections by implementing intelligent retry logic, ensuring that your AI agents and applications stay synchronized with their data sources. By utilizing this within the Openclaw Skills ecosystem, developers can focus on core logic while the skill handles the intricacies of network failure recovery and connection state management.

This skill goes beyond simple retries by incorporating random jitter to prevent thundering herd issues and a circuit breaker pattern to stop cascading failures. It is highly configurable, allowing for fine-tuned control over heartbeat intervals, timeout thresholds, and backoff multipliers, making it suitable for everything from high-frequency trading feeds to casual chat interfaces.

WebSocket Reconnect Use Cases

  • Maintaining persistent connections for real-time AI agent communication channels.
  • Managing high-uptime GraphQL subscriptions in production environments.
  • Implementing resilient data streaming for financial or IoT monitoring dashboards.
  • Protecting backend infrastructure from overload during outages using the circuit breaker pattern.

How WebSocket Reconnect Works

  1. The skill initializes with a target WebSocket URL and specific configuration for retries and heartbeats.
  2. Upon calling the connect method, it establishes a primary connection and starts a heartbeat timer.
  3. The heartbeat mechanism sends periodic ping messages and monitors for pong responses to detect dead connections immediately.
  4. If a connection fails or a heartbeat times out, the skill calculates a delay using an exponential backoff formula combined with random jitter.
  5. During persistent failures, the circuit breaker moves to an OPEN state to stop connection attempts and conserve resources.
  6. Once the reset timeout expires, the skill enters a HALF-OPEN state to test connection viability before fully resuming operations.

WebSocket Reconnect Setup

First, ensure you have the necessary dependencies installed in your environment:

npm install ws

To integrate the skill into your project, use the following initialization pattern:

const { WebSocketReconnect } = require('./scripts/websocket-reconnect.js');

const ws = new WebSocketReconnect({
  url: 'wss://api.your-service.com',
  maxRetries: 10,
  baseDelay: 1000
});

ws.connect();

WebSocket Reconnect Data Schema & Taxonomy

The skill manages connection health through a robust state machine and provides telemetry via the getStats() method.

Attribute Type Description
state String The current connection status (CONNECTING, OPEN, CLOSING, CLOSED, BLOCKED, FAILED)
circuitState String The circuit breaker status (CLOSED, OPEN, HALF-OPEN)
retryCount Number The number of consecutive retry attempts made
lastActivity Timestamp The Unix timestamp of the last successful message or heartbeat

WebSocket Reconnect Advanced Features

  • Smart Exponential Backoff: Prevents aggressive reconnect hammering by increasing delays dynamically.
  • Thundering Herd Protection: Uses random jitter (±10% by default) to de-synchronize multiple clients reconnecting at once.
  • Integrated Circuit Breaker: Automatically pauses connection attempts after a failure threshold to protect the system.
  • Customizable Heartbeats: Allows for custom ping/pong payloads to match specific server-side protocol requirements in Openclaw Skills.
  • Detailed Event Hooks: Provides precise monitoring through events like circuitChange, stateChange, and retry info.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Requires
Bins node
Github Stars: 0
forks: 0

Featured*