WebSocket server middleware for the snub Redis-based messaging framework, version 4.2.1, distributed as an ESM-only package (CJS still supported via dynamic require). Built on uWebSockets.js, it provides a high-performance WebSocket layer with built-in authentication (function, snub event, or HTTP Basic Auth), rate limiting, idle timeout, origin restrictions, backpressure handling, and message offloading to HTTP for large payloads. Requires both snub and Redis. The client protocol uses JSON arrays for structured messaging with reply IDs.
npm install snub-wsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up a basic WebSocket server on port 8585 with no authentication, and listens for 'ws:hello' events.
Use import SnubWS from 'snub-ws' or const SnubWS = require('snub-ws').defaultRemove includeRaw and log manually if needed
Ensure client sends `_auth` message promptly or set auth: false for unauthenticated connections.
Set idleTimeout <= 960000 (or 960 seconds)
Consider using 'maxConnections' to limit clients per IP if needed.
Use dynamic import: const SnubWS = (await import('snub-ws')).defaultUse import SnubWS from 'snub-ws' (default import)
npm install snub