Gathering detailed insights and metrics for reconnecting-websocket
Gathering detailed insights and metrics for reconnecting-websocket
Gathering detailed insights and metrics for reconnecting-websocket
Gathering detailed insights and metrics for reconnecting-websocket
websocket-ts
<div> <div align="center"> <img src="https://raw.githubusercontent.com/jjxxs/websocket-ts/gh-pages/websocket-ts-logo.svg" alt="websocket-ts" width="300" height="65" /> </div> <p align="center"> <img src="https://github.com/jjxxs/websocket-ts
@mylinkpi/reconnecting-websocket
Reconnecting WebSocket
react-native-reconnecting-websocket
websocket module
@eridanussora/reconnecting-websocket
Reconnecting WebSocket
Reconnecting WebSocket. For Web, React Native, cli (Node.js)
npm install reconnecting-websocket
Typescript
Module System
Node Version
NPM Version
99.7
Supply Chain
100
Quality
76
Maintenance
100
Vulnerability
99.6
License
TypeScript (96.33%)
JavaScript (3.67%)
Total Downloads
42,417,603
Last Day
23,759
Last Week
352,265
Last Month
1,525,719
Last Year
13,989,603
MIT License
1,277 Stars
251 Commits
205 Forks
18 Watchers
17 Branches
15 Contributors
Updated on Jul 01, 2025
Minified
Minified + Gzipped
Latest Version
4.4.0
Package Id
reconnecting-websocket@4.4.0
Size
24.68 kB
NPM Version
6.12.1
Node Version
12.13.1
Published on
Feb 07, 2020
Cumulative downloads
Total Downloads
Last Day
-2.6%
23,759
Compared to previous day
Last Week
-10.4%
352,265
Compared to previous week
Last Month
8.6%
1,525,719
Compared to previous month
Last Year
54.6%
13,989,603
Compared to previous year
WebSocket that will automatically reconnect if the connection is closed.
1npm install --save reconnecting-websocket
So this documentation should be valid: MDN WebSocket API.
Ping me if you find any problems. Or, even better, write a test for your case and make a pull request :)
1import ReconnectingWebSocket from 'reconnecting-websocket'; 2 3const rws = new ReconnectingWebSocket('ws://my.site.com'); 4 5rws.addEventListener('open', () => { 6 rws.send('hello!'); 7});
The url
parameter will be resolved before connecting, possible types:
string
() => string
() => Promise<string>
1import ReconnectingWebSocket from 'reconnecting-websocket'; 2 3const urls = ['ws://my.site.com', 'ws://your.site.com', 'ws://their.site.com']; 4let urlIndex = 0; 5 6// round robin url provider 7const urlProvider = () => urls[urlIndex++ % urls.length]; 8 9const rws = new ReconnectingWebSocket(urlProvider);
1import ReconnectingWebSocket from 'reconnecting-websocket'; 2 3// async url provider 4const urlProvider = async () => { 5 const token = await getSessionToken(); 6 return `wss://my.site.com/${token}`; 7}; 8 9const rws = new ReconnectingWebSocket(urlProvider);
1import ReconnectingWebSocket from 'reconnecting-websocket'; 2import WS from 'ws'; 3 4const options = { 5 WebSocket: WS, // custom WebSocket constructor 6 connectionTimeout: 1000, 7 maxRetries: 10, 8}; 9const rws = new ReconnectingWebSocket('ws://my.site.com', [], options);
1type Options = { 2 WebSocket?: any; // WebSocket constructor, if none provided, defaults to global WebSocket 3 maxReconnectionDelay?: number; // max delay in ms between reconnections 4 minReconnectionDelay?: number; // min delay in ms between reconnections 5 reconnectionDelayGrowFactor?: number; // how fast the reconnection delay grows 6 minUptime?: number; // min time in ms to consider connection as stable 7 connectionTimeout?: number; // retry connect if not connected after this time, in ms 8 maxRetries?: number; // maximum number of retries 9 maxEnqueuedMessages?: number; // maximum number of messages to buffer until reconnection 10 startClosed?: boolean; // start websocket in CLOSED state, call `.reconnect()` to connect 11 debug?: boolean; // enables debug output 12};
1WebSocket: undefined, 2maxReconnectionDelay: 10000, 3minReconnectionDelay: 1000 + Math.random() * 4000, 4reconnectionDelayGrowFactor: 1.3, 5minUptime: 5000, 6connectionTimeout: 4000, 7maxRetries: Infinity, 8maxEnqueuedMessages: Infinity, 9startClosed: false, 10debug: false,
1constructor(url: UrlProvider, protocols?: string | string[], options?: Options) 2 3close(code?: number, reason?: string) 4reconnect(code?: number, reason?: string) 5 6send(data: string | ArrayBuffer | Blob | ArrayBufferView) 7 8addEventListener(type: 'open' | 'close' | 'message' | 'error', listener: EventListener) 9removeEventListener(type: 'open' | 'close' | 'message' | 'error', listener: EventListener)
1binaryType: string; 2bufferedAmount: number; 3extensions: string; 4onclose: EventListener; 5onerror: EventListener; 6onmessage: EventListener; 7onopen: EventListener; 8protocol: string; 9readyState: number; 10url: string; 11retryCount: number;
1CONNECTING 0 The connection is not yet open. 2OPEN 1 The connection is open and ready to communicate. 3CLOSING 2 The connection is in the process of closing. 4CLOSED 3 The connection is closed or couldn't be opened.
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 2/15 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More