debugging-websocket-issues

Diagnose WebSocket frame errors from conflicting WebSocketServer instances in Node.js.

790|60|Updated Dec 17, 2025
One-click install
npx skills add https://github.com/khaliqgant/agent-relay --skill debugging-websocket-issues
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debugging-websocket-issues
Source: https://github.com/khaliqgant/agent-relay/tree/main/.claude/skills/debugging-websocket-issues/SKILL.md
Command: npx skills add https://github.com/khaliqgant/agent-relay --skill debugging-websocket-issues

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps diagnose WebSocket errors (Invalid frame header, RSV1, 1006) and conflicts from multiple WebSocketServer instances.

Core Features & Use Cases

  • Identify root causes of RSV1 errors and raw HTTP on upgrade
  • Techniques to debug raw frames and upgrade paths
  • Guidance for avoiding multiple upgrade handlers
  • Use Case: Troubleshoot a WebSocket server that misbehaves under load

Quick Start

Run the debugging workflow when a WebSocket error appears; follow the steps to isolate the cause and implement fixes.

Frequently Asked Questions about debugging-websocket-issues

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

FAQPage Schema
How do I fix WebSocket RSV1 and invalid frame header errors in Node.js?

RSV1 errors occur when multiple WebSocketServer instances handle the same upgrade event, causing conflicting compression settings. Diagnose by checking for duplicate upgrade listeners and verify perMessageDeflate configuration matches across all handlers. Fix by routing upgrades through a single noServer instance or ensuring only one upgrade listener processes each connection.

Why is my WebSocket connection closing with code 1006 or showing raw HTTP data?

Code 1006 abnormal closures and raw HTTP data on upgraded sockets typically signal conflicting WebSocketServer upgrade handlers writing to the same socket. Verify you have exactly one upgrade event listener per server and that raw frames aren't being corrupted by competing handlers. Consolidate upgrade logic into a single handler.

What causes WS_ERR_UNEXPECTED_RSV_1 errors in ws library servers?

This error indicates the compression bit (RSV1) is set when perMessageDeflate is disabled or mismatched between client and server. Check your ws WebSocketServer configuration for conflicting compression settings across multiple instances. Ensure perMessageDeflate is consistently enabled or disabled on all upgrade paths.

How do I debug WebSocket frame errors in a Node.js production environment?

Capture raw frames and trace upgrade listener execution paths to identify which handler processes each connection. Log WebSocketServer instance creation and upgrade event firing to spot duplicate handlers. Verify socket state before and after frame operations to isolate where corruption occurs.

Can I use multiple WebSocketServer instances with the same Node.js HTTP server?

Multiple instances can coexist only if they handle disjoint upgrade paths or use noServer mode with exclusive routing. Overlapping upgrade listeners cause frame errors and 1006 closures. Use a single noServer instance and route upgrades explicitly, or ensure each instance listens on separate paths with clear ownership.

What's the best way to structure WebSocket upgrade handlers to avoid frame corruption?

Use a single noServer WebSocketServer and handle all upgrades through one listener with explicit path or protocol routing. Avoid creating multiple WebSocketServer instances that might claim the same upgrade event. This architecture prevents RSV1 conflicts and ensures consistent compression and frame handling.