Registry / testing / wspr
library2.2.0jsnpmunverified

WebSocket proxy that forwards HTTP POST requests to connected WebSocket clients. Version 2.2.0 is the latest stable release. Useful for testing and mocking WebSocket integrations by converting simple HTTP POST calls into WebSocket broadcasts. Lightweight, zero-config CLI tool with optional SSL support. Differentiates from full WebSocket mocking libraries by focusing on the HTTP-to-WebSocket bridge pattern with minimal setup.

npm install wspr
INSTALL
IMPORT
SIG · WSPR
W
wspr
testingjavascriptv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

wspr CLI
npm i -g wspr
npm install wspr --save-dev
wspr is designed as a global CLI tool. Local install will not expose the 'wspr' command unless added to package.json scripts.

Installs wspr globally, starts the proxy, and demonstrates broadcasting a JSON message via HTTP POST to all connected WebSocket clients.

# Install globally npm i -g wspr # Start the proxy (default ports: WS=3005, HTTP=3006) wspr # In another terminal, connect a WebSocket client (e.g., wscat) # wscat -c ws://localhost:3005 # Send an HTTP POST to broadcast to all WebSocket clients curl -d "{\"hello\": \"world\"}" -X POST http://localhost:3006 # For secure WebSocket (wss), provide cert and key: wspr --cert=./localhost.crt --key=./localhost.key
Debug
Known issues
gotchawspr binds to localhost by default. It will not accept connections from external hosts unless configured otherwise.
fix
Modify the source code or use a reverse proxy to bind to 0.0.0.0 if remote access is required.
affects: >=0.0.0
gotchaThe HTTP proxy endpoint does not support GET requests; only POST. Using GET will result in an error or no broadcast.
fix
Use POST method with a request body (string or JSON) to the HTTP endpoint.
affects: >=0.0.0
deprecatedSSL setup instructions reference self-signed certificates. Modern browsers may reject self-signed certs for WebSocket connections.
fix
Use a trusted certificate authority or use wss with valid certificates.
affects: >=0.0.0
Errors
Common errors & fixes
Command 'wspr' not found
wspr is not installed globally or not in PATH.
fix
Run 'npm i -g wspr' and ensure npm global binaries are in your PATH.
Error: listen EADDRINUSE :::3005
Port 3005 is already in use by another process.
fix
Kill the process on that port (e.g., lsof -ti:3005 | xargs kill) or modify wspr source to use a different port.
WebSocket connection to 'ws://localhost:3005' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
wspr server is not running or firewall is blocking the connection.
fix
Start wspr in a terminal. Ensure no firewall rules block the port.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
packagewspr
wspr — npm install wspr · libregistry