Registry / messaging / phenix-web-reconnecting-websocket

phenix-web-reconnecting-websocket

JSON →
library2020.0.2jsnpmunverified

A lightweight WebSocket wrapper that automatically reconnects on server disconnect and network interruptions. Version 2020.0.2 is the latest stable release. Key differentiator: targeted specifically for PhenixRTS real-time streaming use cases, with minimal configuration. The package provides a drop-in replacement for standard WebSocket with automatic reconnection logic including exponential backoff and event handling.

npm install phenix-web-reconnecting-websocket
INSTALL
IMPORT
SIG · PHENIX-WEB-RECONNE
P
phenix-web-reconnecting-websocket
messagingjavascriptv2020.0.2
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.

default
import ReconnectingWebSocket from 'phenix-web-reconnecting-websocket'
const ReconnectingWebSocket = require('phenix-web-reconnecting-websocket')
Package is ESM-only; use named import if types are needed, though the main export is a class.
ReconnectingWebSocket
import ReconnectingWebSocket from 'phenix-web-reconnecting-websocket'
import { ReconnectingWebSocket } from 'phenix-web-reconnecting-websocket'
Default export only; named import will result in undefined.
WebSocket
import ReconnectingWebSocket from 'phenix-web-reconnecting-websocket'; const ws = new ReconnectingWebSocket(url)
import { WebSocket } from 'phenix-web-reconnecting-websocket'
The class is the default export, not named WebSocket.

Creates a reconnecting WebSocket to a secure WebSocket endpoint and sets up lifecycle event handlers.

import ReconnectingWebSocket from 'phenix-web-reconnecting-websocket'; const ws = new ReconnectingWebSocket('wss://example.com/socket'); ws.onopen = () => console.log('Connected'); ws.onmessage = (event) => console.log('Message:', event.data); ws.onclose = () => console.log('Disconnected'); ws.onerror = (error) => console.error('Error:', error);
Debug
Known issues
gotchaThe constructor does not accept options object; all configuration must be set via instance properties after creation or subclassing.
fix
Use instance properties: ws.reconnectInterval = 5000; or extend the class.
affects: >=2020.0.0
gotchaReconnection may cause duplicate event listeners if onopen/onmessage are reassigned inside event handlers.
fix
Attach event listeners once outside of reconnection callbacks. Use addEventListener pattern if needed.
affects: >=2020.0.0
deprecatedPackage has not been updated since 2020. Consider using modern alternatives like robust-websocket or @rails/actioncable with reconnection logic.
fix
Migrate to actively maintained WebSocket reconnection libraries.
affects: >=2020.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'readyState')
Attempting to access readyState before the WebSocket is initialized (e.g., in constructor).
fix
Access readyState after the 'open' event or use a getter that checks for the underlying socket.
Error: WebSocket is not defined
Using the library in a non-browser environment (e.g., Node.js) without WebSocket polyfill.
fix
Install and import 'ws' package: npm install ws, then import WebSocket from 'ws' before using ReconnectingWebSocket in Node.js.
Uncaught TypeError: this.websocket.onclose is not a function
Incorrectly setting onclose before WebSocket is instantiated or not waiting for constructor completion.
fix
Set onclose after instantiation, not inside the constructor.
Upgrade
Version history
2020.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
2
Amazon
1
Resources
phenix-web-reconnecting-websocket — npm install phenix-web-reconnecting-websocket · libregistry