A drop-in replacement for the WebSocket API that automatically reconnects when the connection is closed. Version 1.0.0 is the latest stable release, actively maintained on GitHub with full test coverage and TypeScript definitions. It is dependency-free, works in browsers, Node.js, ServiceWorkers, and React Native, and supports URL providers for dynamic server selection. Key differentiators: no external dependencies, fully configurable reconnection delays with exponential backoff, connection timeout handling, and debug mode. The package is a fork of reconnecting-websocket with a fix for close event handling.
npm install reconnecting-websocket-fixcloseNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: create a reconnecting WebSocket, listen for events, send/receive messages, and manually reconnect.
Use import or enable esModuleInterop and use const RWS = require('reconnecting-websocket-fixclose').default;Use compatible WebSocket implementations like 'ws' or globalThis.WebSocket.
Add an 'open' event listener to know when reconnection succeeds.
Resolve URL promise within a reasonable time (< connectionTimeout ms) to prevent unnecessary retries.
Wait for 'open' event before sending. Check rws.readyState === WebSocket.OPEN.
Run: npm install reconnecting-websocket-fixclose
No dependency data recorded yet.