diff --git a/lib/cam.js b/lib/cam.js index 7dda802..57b46c4 100755 --- a/lib/cam.js +++ b/lib/cam.js @@ -86,6 +86,7 @@ var Cam = function(options, callback) { this.path = options.path || '/onvif/device_service'; this.timeout = options.timeout || 120000; this.agent = options.agent || false; + this.eventReconnectms = options.eventReconnectms; /** * Force using hostname and port from constructor for the services * @type {boolean} diff --git a/lib/events.js b/lib/events.js index a662d13..2a91f40 100644 --- a/lib/events.js +++ b/lib/events.js @@ -354,6 +354,8 @@ module.exports = function(Cam) { this.createPullPointSubscription(function(error) { if (!error) { this._eventPull(); + } else if (this.eventReconnectms) { + setTimeout(() => this._eventRequest(), this.eventReconnectms); } }.bind(this)); } else {