pr-ws-monitor

0.2.4 • Public • Published

pr-ws-monitor

Websockets connection monitoring

Philosophy

Monitor websockets for activity, and send PINGS for in-active sockets. Close un-responsive connections automatically using periodic auditing.

Installation

$ npm install pr-ws-monitor

APIs

The module exports a class WsMonitor(wss[, options]) with two methods:

  • start
  • stop
var WsMonitor = require('pr-ws-monitor');
    ws = require('ws');

var wss, wsmon;

wss = new ws.Server({
    port: 9090,
    clientTracking: true
});

wsmon = new WsMonitor(wss);

wsmon.start(); // start monitoring all connections to wss
wsmon.stop(); // stop monitoring

The options are a JSON object:

  • ts : time-stamp accuracy (default: 1-sec)
  • error : un-responsive duration after which to close the socket (default: 60-sec)
  • audit : frequency of auditing connections (default: error/4)

Usage

Refer to test spec.js implementation for usage details.

Test

$ npm install # inside pr-ws-monitor
$ npm test

Package Sidebar

Install

npm i pr-ws-monitor

Weekly Downloads

1

Version

0.2.4

License

MIT

Last publish

Collaborators

  • partharamanujam