neilpatel121 / homebridge-skyq-tvremote

Apache License 2.0
10 stars 3 forks source link

Request error crushes homebridge #40

Open jannisgries opened 1 year ago

jannisgries commented 1 year ago

Describe The Bug: In order to save energy, I disconnect my Sky Q box from power with a smart plug. Once the box is completely offline, the plugin throws a Request Error, which forces to shut down the entire Homebridge. After the Hombebridge has restarted, the error is thrown again and the shutdown procedure starts.

To Reproduce: Take Sky Q box of network / power while plugin is running on homebridge.

Expected behavior: Plugin waits for the Sky Q box to come back online while marking the box as shut off or not available.

Logs:

RequestError: Error: connect EHOSTUNREACH 192.168.0.3:9006 at new RequestError (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request/request.js:185:22) at Request.emit (node:events:527:28) at Request.onRequestError (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request/request.js:877:8) at ClientRequest.emit (node:events:527:28) at Socket.socketErrorListener (node:_http_client:454:9) at Socket.emit (node:events:527:28) at emitErrorNT (node:internal/streams/destroy:157:8) { cause: Error: connect EHOSTUNREACH 192.168.0.3:9006 at TCPConnectWrap.afterConnect [as o563456ncomplete] (node:net:1187:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '192.168.0.3', port: 9006 }, error: Error: connect EHOSTUNREACH 192.168.0.3:9006 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '192.168.0.3', port: 9006 }, options: { url: 'http://192.168.0.3:9006/as/system/information', json: true, callback: [Function: RP$callback], transform: undefined, simple: true, resolveWithFullResponse: false, transform2xxOnly: false }, response: undefined }

Environment:

SmolSoftBoi commented 1 year ago

Could you explain your expected behaviour further please?

jannisgries commented 1 year ago

Ah, I misunderstood this section. My expected behaviour would be, that the plugin simply waits for the sky-q-box to come back online again and in the meanwhile shows the box as not available or shut off. Anyhow, the plugin should not throw an error crashing the homebridge.

miticolars commented 1 year ago

Hi, same problem here. I'm running homebridge on a docker image on Synology NAS and with a previous version of the container the plugin logged the error on console, but homebridge stayed on. Now with the new container version (with updated node.js) the homebridge process goes down if my sky q stb is off.

SmolSoftBoi commented 1 year ago

Could you include the environment section, please?

miticolars commented 1 year ago

What kind of details do you need? I mean, nodejs version? Thank you

SmolSoftBoi commented 1 year ago

What kind of details do you need? I mean, nodejs version? Thank you

https://github.com/neilpatel121/homebridge-skyq-tvremote/issues/new?assignees=&labels=bug&template=bug-report.md The section shown on the template.

jannisgries commented 1 year ago

Environment:

SmolSoftBoi commented 1 year ago

Could you test the beta branch please?

miticolars commented 1 year ago

Environment:

Plugin Version: v1.4.1 Homebridge Version: v1.6.0 Node.js Version: v18.12.1 NPM Version: 8.19.2 Operating System: Ubuntu Focal Fossa (20.04.5 LTS)

jannisgries commented 1 year ago

Tested with v1.4.1-beta.0

The homebridge stays online and does not shut down. The following error is logged (see below) every 10 seconds. When Sky Q is coming back online, the plugin does notice Sky Q, no errors.

Logs: RequestError: Error: connect EHOSTUNREACH 192.168.0.3:9006 at new RequestError (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/plumbing.js:87:29) at Request.RP$callback [as _callback] (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request-promise-core/lib/plumbing.js:46:31) at self.callback (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request/request.js:185:22) at Request.emit (node:events:527:28) at Request.onRequestError (/var/lib/homebridge/node_modules/homebridge-skyq-tvremote/node_modules/request/request.js:877:8) at ClientRequest.emit (node:events:527:28) at Socket.socketErrorListener (node:_http_client:454:9) at Socket.emit (node:events:527:28) at emitErrorNT (node:internal/streams/destroy:157:8) { cause: Error: connect EHOSTUNREACH 192.168.0.3:9006 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '192.168.0.3', port: 9006 }, error: Error: connect EHOSTUNREACH 192.168.0.3:9006 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) { errno: -113, code: 'EHOSTUNREACH', syscall: 'connect', address: '192.168.0.3', port: 9006 }, options: { url: 'http://192.168.0.3:9006/as/system/information', json: true, callback: [Function: RP$callback], transform: undefined, simple: true, resolveWithFullResponse: false, transform2xxOnly: false }, response: undefined } [06/12/2022, 11:58:28] [skyq-tvremote] [Sky Q] Perhaps the IP address is incorrect

miticolars commented 1 year ago

Hi, any news about the release of the fix?

It seems that Homebridge crashes only during the startup if the plugin cannot reach the Sky Box. If homebridge is already running, the plugin write only an error in the console.

Thanks Paolo