rust-websocket

Build Rust WebSocket clients with keep-alive, reconnection, and subscription persistence.

1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/anicdh/agstack --skill rust-websocket
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-websocket
Source: https://github.com/anicdh/agstack/tree/main/.claude/skills/rust/rust-websocket
Command: npx skills add https://github.com/anicdh/agstack --skill rust-websocket

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Long-running WebSocket workflows in Rust are error-prone without robust lifecycle management. This skill provides production-grade patterns for PING/keep-alive, reconnection with cleanup, interval task lifecycle, and subscription management to ensure stable streams.

Core Features & Use Cases

  • PING/keep-alive scheduling with a single, dedicated interval.
  • Clean reconnection workflow: terminate old tasks, reset state, and re-subscribe on reconnect.
  • Subscription management with persistence to auto-resubscribe after reconnects.
  • Production-ready messaging loop with separate reader/writer tasks and safe shutdown.

Quick Start

Instantiate the Rust WebSocket client with the target URL and call its run loop, then subscribe to desired topics.

Frequently Asked Questions about rust-websocket

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle WebSocket reconnection and keep-alive in a Rust Tokio application?

WebSocket reconnection in Rust requires a dedicated ping loop and backoff-based reconnect tasks to reset state and re-subscribe. This pattern ensures stable streams by safely terminating old tasks using cancellation tokens during cleanup.

What is the best way to manage WebSocket subscriptions that need automatic resubscribe after disconnects?

Subscription management with persistence automatically resubscribes to desired topics after reconnects. By maintaining topic state separately, the client can rebuild WebSocket streams without losing real-time data feeds.

How do I implement a clean shutdown for a long-running Rust WebSocket client?

Clean shutdown for a Rust WebSocket client uses cancellation tokens and Tokio utilities to safely terminate separate reader and writer tasks. This prevents resource leaks when ending long-running connections.

Does this Rust WebSocket pattern work for trading bots and real-time data feeds?

Yes, this Rust WebSocket pattern is designed for trading bots and real-time data feeds requiring stable streams. It handles long-running connections with reliable keep-alive and automatic reconnection workflows.

Why does my Rust WebSocket connection drop without a dedicated ping loop?

A Rust WebSocket connection drops without a dedicated ping loop because keep-alive intervals are required to maintain long-running connections. Scheduling a single interval prevents silent disconnects in real-time data streams.