axum-websocket

Standardize WebSocket message types, room broadcasting, and heartbeats in Axum 0.8.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill axum-websocket
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axum-websocket
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/axum-websocket
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill axum-websocket

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implement robust WebSocket handling in Axum 0.8, standardizing Message types, broadcasting, and heartbeat management to reduce boilerplate and errors.

Core Features & Use Cases

  • Basic upgrade with correct Message type usage (Utf8Bytes/Text vs Binary)
  • Stateful connections with per-connection AppState
  • Broadcast rooms using tokio::sync::broadcast for multi-client live feeds
  • Heartbeat and close-code handling to maintain healthy connections
  • Use Cases: chat, live dashboards, pub/sub-style real-time updates in Axum

Quick Start

Add a WebSocket route to your Axum app and wire a handler that supports text and binary frames with heartbeat, broadcasting, and proper close-code handling.

Frequently Asked Questions about axum-websocket

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

FAQPage Schema
How do I add real-time WebSocket support to an Axum app?

Add real-time WebSocket support to your Axum app by wiring a handler that manages message upgrades, broadcast rooms, and heartbeat cycles. This standardizes text and binary frame handling and reduces boilerplate for real-time features like chat and live feeds.

How do I broadcast WebSocket messages to multiple clients in Rust?

Broadcast WebSocket messages to multiple clients in Rust using tokio::sync::broadcast channels within Axum routes. This pattern creates broadcast rooms that efficiently distribute live updates or pub/sub events across all connected clients per room.

How do I manage per-connection state in an Axum WebSocket handler?

Manage per-connection state in an Axum WebSocket handler by implementing stateful upgrades with dedicated AppState for each connection. This isolates connection-specific data and logic, enabling robust multi-route real-time features and individual client tracking.

Why do my Axum WebSocket connections drop unexpectedly, and how do I implement a heartbeat?

Axum WebSocket connections drop unexpectedly without active keep-alive signals. Implement a heartbeat mechanism using Tokio intervals to periodically ping clients and manage proper close codes, maintaining healthy connections and detecting dead peers.

Does this WebSocket Skill support Axum 0.8 and proper message type handling?

Yes, this WebSocket Skill explicitly supports Axum 0.8 and standardizes correct Message type usage, differentiating between Utf8Bytes/Text and Binary frames. It ensures proper close-code handling and reduces type-mismatch errors during real-time communication.

What is the best way to handle WebSocket close codes in an Axum application?

The best way to handle WebSocket close codes in an Axum application is to standardize explicit close-code management within your handler logic. Proper close-code handling ensures clean connection termination and prevents resource leaks in real-time pub/sub systems.