homebridge-harmony icon indicating copy to clipboard operation
homebridge-harmony copied to clipboard

[BUG] Socket close

Open scottleestrange opened this issue 2 years ago • 2 comments

*Describe the bug Periodic socket close

IOS (please complete the following information): HOOBS 4.2.5 node 16.15.0

Logs Your log in debug mode (-D option)

5/7/2022, 9:59:31 AMHarmony BridgeLoft(Master)ERROR (1)- refreshCurrentActivity Error: WebSocket closed with reason: undefined (undefined). - Stack : Error: WebSocket closed with reason: undefined (undefined). at WebSocketAsPromised._handleClose (/var/lib/hoobs/harmonybridge/node_modules/websocket-as-promised/src/index.js:353:19) at WebSocket.listener (/var/lib/hoobs/harmonybridge/node_modules/websocket-as-promised/src/index.js:311:64) at WebSocket.emit (node:events:527:28) at WebSocket.emitClose (/var/lib/hoobs/harmonybridge/node_modules/ws/lib/websocket.js:243:10) at Socket.socketOnClose (/var/lib/hoobs/harmonybridge/node_modules/ws/lib/websocket.js:1031:15) at Socket.emit (node:events:527:28) at TCP. (node:net:709:12) 5/7/2022, 9:59:31 AMHarmony BridgeLoft(Master)WARNING - socket closed

Config Your config section of platform. Please do not post your whole config and especially with logins / passwords !

Additional context Add any other context about the problem here.

scottleestrange avatar May 07 '22 17:05 scottleestrange

I am having the same issue on Homebridge 1.4.1

simplytoast1 avatar May 08 '22 23:05 simplytoast1

Hi,

I don't support hoobs . If the problem appears on homebridge, please post the logs here .

nicoduj avatar Sep 04 '22 08:09 nicoduj

I got similar Errors on Homebridge 1.5.0

[9/29/2022, 12:46:47 PM] [Harmony] (Harmony)INFO - Loading activities... [9/29/2022, 12:46:57 PM] [Harmony] (Harmony)ERROR (1)- refreshCurrentActivity Error: WebSocket closed with reason: undefined (undefined). - Stack : Error: WebSocket closed with reason: undefined (undefined). at WebSocketAsPromised._handleClose (/volume3/homebridge/node_modules/homebridge-harmony/node_modules/websocket-as-promised/src/index.js:353:19) at WebSocket.listener (/volume3/homebridge/node_modules/homebridge-harmony/node_modules/websocket-as-promised/src/index.js:311:64) at WebSocket.emit (node:events:513:28) at WebSocket.emitClose (/volume3/homebridge/node_modules/homebridge-harmony/node_modules/ws/lib/websocket.js:246:10) at Receiver.receiverOnFinish (/volume3/homebridge/node_modules/homebridge-harmony/node_modules/ws/lib/websocket.js:1049:20) at Receiver.emit (node:events:513:28) at finish (node:internal/streams/writable:756:10) at processTicksAndRejections (node:internal/process/task_queues:83:21) [9/29/2022, 12:46:57 PM] [Harmony] (Harmony)WARNING - socket closed [9/29/2022, 12:47:12 PM] [Harmony] (Harmony)Error - Error connecting after socket closed network timeout at: http://192.168.1.107:8088/

And my Config:

{ "name": "Harmony", "hubIP": "192.168.1.107", "hubName": "Harmony", "DELAY_BEFORE_RETRY_AFTER_NETWORK_LOSS": 60000, "HUB_CONNECT_TIMEOUT": 10000, "HUB_SEND_TIMEOUT": 30000, "cleanCache": false, "TVAccessory": false, "sortInput": 0, "switchAccessories": true, "publishSwitchActivitiesAsIndividualAccessories": true, "otherPlatforms": [ { "sortInput": 0 } ], "platform": "HarmonyHubWebSocket"

TheBassfly avatar Sep 29 '22 11:09 TheBassfly

Here is a log. What's up wit this?image

grantdray avatar Sep 30 '22 19:09 grantdray

can you try removing : "otherPlatforms": [ { "sortInput": 0 }

nicoduj avatar Oct 17 '22 12:10 nicoduj

I'm having this issue as well on v1.6.1 (and Homebridge 1.5.0), over the past few months my rpi with homebridge install becomes unresponsive on the network several times a week until I restart my Harmony hub, Homebridge logs are just filled with line after line after line of (occasionally interrupted by other plugins complaining due to not being able to reach other services online)

[31/10/2022, 19:03:09] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:03:22] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:04:01] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:04:09] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:04:14] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:04:27] [Harmony Hub] (Harmony Hub)WARNING - socket closed [31/10/2022, 19:05:06] [Harmony Hub] (Harmony Hub)WARNING - socket closed

followed by a single

[31/10/2022, 19:08:12] [Harmony Hub] (Harmony Hub)Error - Error connecting after socket closed request to http://192.168.1.229:8088/ failed, reason: connect ECONNREFUSED 192.168.1.229:8088

at the time when I unplugged the harmony hub. Then everything's fine for a few days until it happens again.

I cannot repro this on purpose so I don't think I can get logs of this in debug mode unless I just leave homebridge running in debug mode indefinitely.. it's also hours and hours of the "socket closed" warning, multiple times every minute, that I don't know when they actually started to try and scroll back and see if there was some other error message prior to them. I know that's not helpful, sorry.

        {
            "name": "Harmony Hub",
            "hubIP": "192.168.1.229",
            "hubName": "Harmony Hub",
            "DELAY_BEFORE_RETRY_AFTER_NETWORK_LOSS": 60000,
            "HUB_CONNECT_TIMEOUT": 10000,
            "HUB_SEND_TIMEOUT": 30000,
            "cleanCache": false,
            "publishAllTVAsExternalAccessory": false,
            "TVAccessory": false,
            "sortInput": 0,
            "playPauseBehavior": false,
            "switchAccessories": true,
            "activitiesToPublishAsAccessoriesSwitch": [
                "Watch Living Room Apple TV",
                "Watch Bedroom Apple TV",
                "Play PS5",
                "Play Switch"
            ],
            "showTurnOffActivity": "inverted",
            "publishGeneralMuteSwitch": false,
            "publishGeneralVolumeSlider": false,
            "linkVolumeControlToTV": false,
            "platform": "HarmonyHubWebSocket"
        }

grelca avatar Nov 01 '22 02:11 grelca

Hi, if other plugins are complaining on not reaching, maybe your pi loose its network / dns for some reason ? You can always try to put harmony plugin on a dedicated hub in homebridge and see if it helps, but I am not sure the plugin is the root cause, it seems homebridge / node cannot "reach" your network.

nicoduj avatar Nov 01 '22 17:11 nicoduj

Well, but the reason I think it's related is that the pi regains network connectivity as soon as I unplug the Harmony hub to restart it. Once the hub is unplugged, the plugin log messages switch from "socket closed" over and over to just one "error connecting" and the pi's network connectivity is totally restored. It's like the plugin is using up all of the pi's networking resources on a bunch of failed websockets or something, and once the IP it's trying to connect to is actually gone from the network, then it finally releases them

This is definitely all hypothesis on my part, though. Except the bit where unplugging the physical Harmony hub device fixes it.

grelca avatar Nov 01 '22 18:11 grelca

Hi, thanks, I did not understood that. I have never restarted my pi running homebridge and the plugin (and others), but there might be some condition there on network loss that indeed leak some sockets . Will try to search in this direction as soon as I have some time ...

nicoduj avatar Nov 01 '22 19:11 nicoduj

Just as a FYI (may not be your issue). I use HOOBS. I did a HOOBS update and my DNS was hosed

All I had to do was pot my router IP in resolve.conf 192.168.1.1 - That waty out would use my routers DNS settings

Doing that and reboot fixed my home bridge related dns issues

Log into your pi and try to ping anything in the network bay name to any site. If you cannot get there it is a dns issue and probably because your pi cannot see the DNS configs of your network

On Nov 1, 2022, at 10:16 AM, Nicolas Dujardin @.***> wrote:

Hi, if other plugins are complaining on not reaching, maybe your pi loose its network / dns for some reason ? You can always try to put harmony plugin on a dedicated hub in homebridge and see if it helps, but I am not sure the plugin is the root cause, it seems homebridge / node cannot "reach" your network.

— Reply to this email directly, view it on GitHub https://github.com/nicoduj/homebridge-harmony/issues/402#issuecomment-1298855901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2J4BUR6RFD5ECEA3E64LDWGFF5JANCNFSM5VKVLS7A. You are receiving this because you authored the thread.

scottleestrange avatar Nov 01 '22 21:11 scottleestrange