A robust, reconnecting WebSocket client for the browser that wraps the standard WebSocket API with automatic reconnection, online/offline awareness, and configurable reconnect strategies. Version 1.0.3 is the current stable release, last updated in 2020. It differentiates from alternatives like reconnecting-websocket by providing native error-code awareness (skipping reconnection on HTTP 400/500 equivalent codes), online/offline detection to avoid battery drain, and a functional composition approach for custom reconnect logic via the shouldReconnect callback. Includes TypeScript type definitions and supports a function-based URL for dynamic endpoint selection. No known security issues.
npm install altamoon-robust-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating a RobustWebSocket with custom reconnect strategy and event listeners.
Update to new constructor: new RobustWebSocket(url, protocols, options) where options is an object.
Set automaticOpen: true or call open() only when needed.
Override shouldReconnect to include these codes if desired.
Use a function if dynamic URLs are needed, e.g., (ws) => ws.reconnects > 0 ? ... : ...
Use ws.reconnects for persistent count; ws.attempts resets per successful connection.
Use default import: import RobustWebSocket from 'robust-websocket'
Run: npm install robust-websocket
Instantiate with: new RobustWebSocket(url)
Ignore this if it happens during navigation; it's expected behavior.
No dependency data recorded yet.