npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wsdctl

v1.0.0

Published

CLI tool for managing WebSocket connections via a background daemon

Readme

wsdctl

A CLI tool for managing WebSocket connections. A background daemon keeps connections alive between commands, making it easy to test WebSocket-based flows step by step.

Zero config. The daemon starts automatically on first use.

Install

npm install -g wsdctl

Requires Node.js 22+ (uses native WebSocket support).

Quick Start

# Connect to a WebSocket server
wsdctl connect wss://example.com/ws --id app

# Send a message and wait for a response
wsdctl send app '{"action":"ping"}' --wait --timeout 3000

# View all traffic
wsdctl messages app

# Disconnect
wsdctl disconnect app

Commands

| Command | Description | |---------|-------------| | connect <url> | Open a WebSocket connection | | send <id> <msg> | Send a message | | wait <id> | Wait for an incoming message | | messages <id> | View message history | | status <id> | Inspect a connection | | list | List active connections | | disconnect <id> | Close a connection | | reconnect <id> | Reopen a closed connection | | closed | List recently closed connections | | clear <id> | Clear message history | | stop | Stop the daemon | | help [cmd] | Show help |

Run wsdctl help <command> for detailed usage of any command.

Connect

wsdctl connect <url> [--id <alias>] [--header <K:V>]... [--message <msg>] [--wait] [--timeout <ms>] [--match <str>]
wsdctl connect wss://example.com/ws                                    # auto-id (c1, c2, ...)
wsdctl connect wss://example.com/ws --id app                           # custom id
wsdctl connect wss://example.com/ws --header "Authorization:Bearer t"  # custom header
wsdctl connect wss://example.com/ws --header "Auth:t" --header "X:v"   # multiple headers
wsdctl connect wss://example.com/ws --timeout 5000                     # handshake timeout
wsdctl connect wss://example.com/ws --message '{"type":"hello"}'       # send on connect
wsdctl connect wss://example.com/ws --message '{"type":"hello"}' --wait --timeout 5000  # send + wait

Send

wsdctl send <id> <message> [--wait] [--timeout <ms>] [--match <str>]
wsdctl send app hello                                          # simple text
wsdctl send app '{"type":"ping"}'                              # JSON
wsdctl send app '{"type":"ping"}' --wait                       # send and wait for reply
wsdctl send app '{"type":"ping"}' --wait --match "pong"        # wait for specific reply
wsdctl send app '{"type":"ping"}' --wait --match '/ok/i'       # regex match

Wait

wsdctl wait <id> [--timeout <ms>] [--match <str>]

Blocks until the next incoming message (or timeout). With --match, skips messages that don't match.

Match Patterns

--match works with wait, send --wait, and connect --wait:

  • Substring: --match "pong" -- matches if the message contains "pong"
  • Regex: --match '/pattern/flags' -- regular expression (e.g. '/status":\s*"ok/i')

Disconnect

wsdctl disconnect <id>                       # fire-and-forget
wsdctl disconnect <id> --wait                # block until close frame (10s default)
wsdctl disconnect <id> --wait --timeout 5000 # custom timeout
wsdctl disconnect --all                      # close all connections

Reconnect

wsdctl reconnect <id>

Reopens a closed connection using the same URL and headers. The connection must be in the closed history (last 50 are kept).

JSON Output

All commands support --json for machine-readable output:

wsdctl list --json
wsdctl status app --json
wsdctl messages app --json
wsdctl send app '{"type":"ping"}' --wait --json

Example Flow

# 1. Connect, send initial message, wait for confirmation
wsdctl connect wss://api.example.com/ws --id app \
  --header "Authorization:Bearer token" \
  --message '{"action":"subscribe","channel":"updates"}' \
  --wait --timeout 5000 --match "subscribed"

# 2. Send request and get response
wsdctl send app '{"action":"query","id":1}' --wait --timeout 3000

# 3. Review full traffic
wsdctl messages app

# 4. Check connection state
wsdctl status app

# 5. Clean disconnect
wsdctl disconnect app --wait

# 6. Reconnect later (same url + headers)
wsdctl reconnect app

# 7. Done — close everything
wsdctl disconnect --all
wsdctl stop

How It Works

wsdctl runs a lightweight background daemon that holds WebSocket connections open. The CLI communicates with the daemon over a Unix socket (/tmp/wsdctl.sock). This allows connections to persist across commands without keeping a terminal open.

  • Daemon starts automatically on the first command that needs it
  • Daemon logs: /tmp/wsdctl.log
  • Stop manually with wsdctl stop

Claude Code Integration

wsdctl ships with a Claude Code skill for AI-assisted WebSocket testing:

wsdctl setup-skill

This copies the skill file to ~/.claude/skills/wsdctl/SKILL.md. After that, Claude Code can use wsdctl to test WebSocket connections on your behalf.

License

ISC