
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Simple auto-reconnect WebSocket adapter
npm i elws -S
const RWS = require('elws');
const client = new RWS('ws://echo.websocket.org;ws://localhost:8080');
client.onopen = function () {
// as soon as we are connected
// just send an Hello World! to the server
client.send('Hello World!');
};
client.onmessage = function (event) {
// because the server is echo.websocket.org we should receive
// "Hello World!" right after connection
console.log('> ', event.data);
};
// connect
client.connect();
//close
setTimeout(function(){
console.log('timeout ');
client.forceClose(1000);
},10000);
If
ws://echo.websocket.org
is unreachable, RWebSocket will try to reconnect once every 3 seconds (default) and try 3 times, then switch another url
See example.js for detailed usage.
The only modifications to the API are:
retryInterval
in ms
retryCount
#connect()
method to actually create a WebSocket and connect to the serverconst client = new RWS('ws://echo.websocket.org;ws://localhost:8080', null, 25000,5);
Reconnection attempts will be made once every 25 seconds, and try 5 times then switch another url. NB: the 'null' param is for the protocol because the constructor is the same as the WebSocket RFC +
retryInterval
the ability to give a one argument to the constructor to set the close event 'code'
client.forceClose(1000);
FAQs
Simple auto-reconnect WebSocket decorator
The npm package elws receives a total of 24 weekly downloads. As such, elws popularity was classified as not popular.
We found that elws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.