From 2abfc1bb91ed1043071e7d110640c871b6c919fa Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Tue, 12 Jul 2022 11:44:35 -0700 Subject: [PATCH] unifi-protect: restart the entire plugin if websocket times out. revisit this as this is bad when there are multiple udm hubs being managed and only 1 is offline. --- external/unifi-protect | 2 +- plugins/unifi-protect/package-lock.json | 4 ++-- plugins/unifi-protect/package.json | 2 +- plugins/unifi-protect/src/main.ts | 6 ++---- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/external/unifi-protect b/external/unifi-protect index 564bfda55..539513af9 160000 --- a/external/unifi-protect +++ b/external/unifi-protect @@ -1 +1 @@ -Subproject commit 564bfda557532cd9b57bb7aceb71370a72de7dca +Subproject commit 539513af925a35ecc82aa1b4c47b372d0a1aeb39 diff --git a/plugins/unifi-protect/package-lock.json b/plugins/unifi-protect/package-lock.json index c3c9085ca..27983f7ff 100644 --- a/plugins/unifi-protect/package-lock.json +++ b/plugins/unifi-protect/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/unifi-protect", - "version": "0.0.118", + "version": "0.0.119", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/unifi-protect", - "version": "0.0.118", + "version": "0.0.119", "hasInstallScript": true, "license": "Apache", "dependencies": { diff --git a/plugins/unifi-protect/package.json b/plugins/unifi-protect/package.json index 93e6324b8..dadc5b2e1 100644 --- a/plugins/unifi-protect/package.json +++ b/plugins/unifi-protect/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/unifi-protect", - "version": "0.0.118", + "version": "0.0.119", "description": "Unifi Protect Plugin for Scrypted", "author": "Scrypted", "license": "Apache", diff --git a/plugins/unifi-protect/src/main.ts b/plugins/unifi-protect/src/main.ts index a0cb71109..fe55555d4 100644 --- a/plugins/unifi-protect/src/main.ts +++ b/plugins/unifi-protect/src/main.ts @@ -270,10 +270,8 @@ export class UnifiProtect extends ScryptedDeviceBase implements Settings, Device } const onWsTimeout = () => { - this.console.log('Event Listener timeout. Restarting listener.'); - this.api?.eventsWs?.removeAllListeners(); - this.api?.eventsWs?.close(); - this.discoverDevices(0); + this.console.log('Event Listener timeout. Restarting plugin.'); + sdk.deviceManager.requestRestart(); }; let wsTimeout: NodeJS.Timeout; const resetWsTimeout = () => {