Socket
Socket
Sign inDemoInstall

websocket.js

Package Overview
Dependencies
2
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    websocket.js

WebSocket browser client with reconnect back-off feature.


Version published
Weekly downloads
75
increased by66.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

websocket.js

WebSocket browser client with reconnect back-off feature.

Usage

WebSocketClient behaves exactly in the same way as WebSocket.

It accepts an optional third parameter, which is used to configure backoff feature.

// fibonacci backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', null, {
  strategy: "fibonacci",
  randomisationFactor: 0, // defaults to 0, must be between 0 and 1
  initialDelay: 10,       // defaults to 100 ms
  maxDelay: 300           // defaults to 10000 ms
});
// exponential backoff strategy
var conn = new WebSocketClient('ws://' + host + ':8080', null, {
  strategy: "exponential",
  randomisationFactor: 0, // defaults to 0, must be between 0 and 1
  initialDelay: 10,       // defaults to 100 ms
  maxDelay: 300,          // defaults to 10000 ms
  factor: 3               // defaults to 2, must be greater than 1
});

Event Listeners

  • onclose
  • onerror
  • onmessage
  • onopen
  • onreconnect

License

MIT

FAQs

Last updated on 16 Jun 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc