pr-ws-monitor
v0.2.4
Published
Websockets monitoring
Downloads
8
Maintainers
Readme
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