Gathering detailed insights and metrics for shopify-reconnecting-websocket
Gathering detailed insights and metrics for shopify-reconnecting-websocket
Gathering detailed insights and metrics for shopify-reconnecting-websocket
Gathering detailed insights and metrics for shopify-reconnecting-websocket
npm install shopify-reconnecting-websocket
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
2 Stars
83 Commits
2 Forks
10 Watching
2 Branches
6,922 Contributors
Updated on 30 Jan 2023
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
37.5%
499
Compared to previous day
Last week
10%
2,033
Compared to previous week
Last month
-75.7%
13,002
Compared to previous month
Last year
695.9%
562,585
Compared to previous year
No dependencies detected.
A small JavaScript library that decorates the WebSocket API to provide a WebSocket connection that will automatically reconnect if the connection is dropped.
It is API compatible, so when you have:
1var ws = new WebSocket('ws://....');
you can replace with:
1var ws = new ReconnectingWebSocket('ws://....');
Minified library with gzip compression is less than 600 bytes.
With the standard WebSocket
API, the events you receive from the WebSocket instance are typically:
onopen
onmessage
onmessage
onmessage
onclose // At this point the WebSocket instance is dead.
With a ReconnectingWebSocket
, after an onclose
event is called it will automatically attempt to reconnect. In addition, a connection is attempted repeatedly (with a small pause) until it succeeds. So the events you receive may look something more like:
onopen
onmessage
onmessage
onmessage
onclose
// ReconnectingWebSocket attempts to reconnect
onopen
onmessage
onmessage
onmessage
onclose
// ReconnectingWebSocket attempts to reconnect
onopen
onmessage
onmessage
onmessage
onclose
This is all handled automatically for you by the library.
1var socket = new ReconnectingWebSocket(url, protocols, options);
url
protocols
options
Options can either be passed as the 3rd parameter upon instantiation or set directly on the object after instantiation:
1var socket = new ReconnectingWebSocket(url, null, {debug: true, reconnectInterval: 3000});
or
1var socket = new ReconnectingWebSocket(url); 2socket.debug = true; 3socket.timeoutInterval = 5400;
debug
console.debug()
.true
or false
false
automaticOpen
true
or false
true
reconnectInterval
integer
1000
maxReconnectInterval
integer
30000
####reconnectDecay
integer
or float
1.5
timeoutInterval
integer
2000
maxReconnectAttempts
integer
or null
.null
binaryType
'blob'
or 'arraybuffer'
.'blob'
ws.open()
ws.close(code, reason)
code
is optional the closing code (default value 1000). https://tools.ietf.org/html/rfc6455#section-7.4.1reason
is the optional reason that the socket is being closed. https://tools.ietf.org/html/rfc6455#section-7.1.6ws.refresh()
ws.send(data)
Like this? Check out websocketd for the simplest way to create WebSocket backends from any programming language.
No vulnerabilities found.
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
no SAST tool detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-07-01
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