Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
boomerang-socket
Advanced tools
Boomerang Socket is a small JavaScript library that extends the native WebSocket API to allow automatic reconnection if a client is disconnected.
npm install boomerang-socket
npm run test
It can be used in exactly the same way as a native WebSocket, with exactly the same API.
// ES2015
import BoomerangSocket from "boomerang-socket";
// Or CommonJS
const BoomerangSocket = require("boomerang-socket");
const socket = new BoomerangSocket("wss://localhost:5000");
socket.addEventListener("open", (event) => {
socket.send("Hello server!");
});
socket.onmessage = (event) => {
console.log("Message from server: ", event.data);
};
The only difference is that the BoomerangSocket
constructor accepts an additional third argument: an options config object which customises the auto-reconnect behaviour.
const socket = new BoomerangSocket("wss://localhost:8080", undefined, {
reconnectAttempts: 25,
reconnectDelay: 5000,
});
name | type | default | description |
---|---|---|---|
connectTimeout | number | 250 | millisecond timeout before a new connection must return open |
reconnect | boolean | true | enables or disables auto-reconnection |
reconnectAttempts | number | Infinity | maximum number of reconnection attempts |
reconnectDelay | number | 3000 | millisecond delay until first reconnection attempt |
reconnectDelayExponent | number | 1.05 | exponent applied to reconnectDelay between each reconnection attempt |
We actively welcome any contributions. You can open a Pull Request here.
FAQs
A simple WebSocket wrapper with automatic reconnection
We found that boomerang-socket 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.