From cbefaa347876fcc854d327e4794a9cb5e95be9bd Mon Sep 17 00:00:00 2001 From: Harry Martland Date: Mon, 13 May 2024 20:33:09 +0100 Subject: [PATCH] adds retry when pull subscriptions fails --- lib/cam.js | 1 + lib/events.js | 2 ++ 2 files changed, 3 insertions(+) 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 3fd1fc2..512dbcf 100644 --- a/lib/events.js +++ b/lib/events.js @@ -349,6 +349,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 {