vectronic / homebridge-nut

Homebridge plugin for NUT (Network UPS Tools) Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reconnect problem

MichlW opened this issue · comments

Hi vectronic,

without a known reason my ups-clients sometimes get disconnected from the upsd running on Synology NAS. The problem is that your plugin does not correctly reconnect and stays disconnected forever.

[7/9/2021, 7:37:26 AM] [Nut] nutClose()
[7/9/2021, 7:37:37 AM] [Nut] (re-)started nut client for nas.fritz.box:3493
[7/9/2021, 7:37:37 AM] [Nut] nutError(Error: connect ECONNREFUSED 172.16.2.240:3493)
[7/9/2021, 7:37:37 AM] [Nut] nutClose()

After restarting homebridge everything works again.

For comparison the following is the nut-client log from a Raspberry Pi 4 also connected to the upsd on Synology:

Jul  9 07:37:30 smarthomepi upsmon[29437]: Poll UPS [ups@nas.fritz.box] failed - Server disconnected
Jul  9 07:37:30 smarthomepi upsmon[29437]: Communications with UPS ups@nas.fritz.box lost
Jul  9 07:37:35 smarthomepi upsmon[29437]: UPS [ups@nas.fritz.box]: connect failed: Connection failure: Connection refused
Jul  9 07:37:40 smarthomepi upsmon[29437]: UPS [ups@nas.fritz.box]: connect failed: Connection failure: Connection refused
Jul  9 07:37:45 smarthomepi upsmon[29437]: Communications with UPS ups@nas.fritz.box established

As you can see, the timestamp is exactly the same as in homebridge log but the connection here gets re-established after 15 seconds.

Could you please have a look to your plugin, why it does not correctly (more often?) try to reconnect to the upsd?

Thanks alot!
Greets

Hi there, thanks for the report. I’ll try to investigate in the next week and get back to you.

@MichlW try version 2.1.1 - I have changed the polling mechanism for connecting to nuts and then for polling UPS devices. Hopefully this fixes your issue without introducing any others...

Thank you! I installed it immediately and will report as soon as I can see some working reconnects.

@vectronic
After three working reconnects I think you got it. Many thanks!
Here is one example!

[7/15/2021, 7:14:43 AM] [Nut] nutClose()
[7/15/2021, 7:14:46 AM] [Nut] starting nut client for nas.fritz.box:3493
[7/15/2021, 7:14:46 AM] [Nut] nutError(Error: connect ECONNREFUSED 172.16.2.240:3493)
[7/15/2021, 7:14:46 AM] [Nut] nutClose()
[7/15/2021, 7:14:51 AM] [Nut] starting nut client for nas.fritz.box:3493
[7/15/2021, 7:14:51 AM] [Nut] nutError(Error: connect ECONNREFUSED 172.16.2.240:3493)
[7/15/2021, 7:14:51 AM] [Nut] nutClose()
[7/15/2021, 7:14:56 AM] [Nut] starting nut client for nas.fritz.box:3493
[7/15/2021, 7:14:56 AM] [Nut] nutError(Error: connect ECONNREFUSED 172.16.2.240:3493)
[7/15/2021, 7:14:56 AM] [Nut] nutClose()
[7/15/2021, 7:15:01 AM] [Nut] starting nut client for nas.fritz.box:3493
[7/15/2021, 7:15:01 AM] [Nut] nut client connected, reported devices: ups=Description unavailable

Excellent news. Thanks for reporting the issue.