node-red-contrib-home-assistant-websocket icon indicating copy to clipboard operation
node-red-contrib-home-assistant-websocket copied to clipboard

Nodered disconnects from Home Assistant

Open schwickster opened this issue 1 year ago • 15 comments

Describe the bug

Hey,

The latest Nodered version (4.0.1) seems to constantly disconnect Home Assistant which prevents events from triggering. In the logging I do see a disconnection and it reconnects.. but.. it still does not seem to properly reconnect. Reverting back to Nodered 4.0.0 seems to work for now. So I don't know if it's a bug within Nodered or a bug within this addon in combination with the latest version.

To Reproduce

Seems random.. so can't reproduce. Nodered 4.0.1 just seems to disconnect events from Home Assistant. Restarting nodered seems to temporary resolve the issue. Downgrading to Nodered 4.0.0 seems to work for now.

Expected behavior

No response

Screenshots

See next response

Example Flow

No response

Environment Information

I'm not at my home computer right now. But using docker version 4.0.1 (and now 4.0.0 for the workaround) of nodered using the latest version of this addon (0.65.1). Home Assistant is also running on docker using version 2024.6.4

Additional context

No response

schwickster avatar Jun 27 '24 10:06 schwickster

IMG_2048

here's some logging.

schwickster avatar Jun 27 '24 10:06 schwickster

Maybe the problem is related to a deprecated alias in HA

`2024-06-27 11:56:50.110 WARNING (ImportExecutor_0) [homeassistant.helpers.typing] HomeAssistantType was used from nodered, this is a deprecated alias which will be removed in HA Core 2025.5. Use homeassistant.core.HomeAssistant instead, please report it to the author of the 'nodered' custom integration

juampe avatar Jun 27 '24 10:06 juampe

Same issue here. However, the "NR websocket disconnect from HA" issue has been with us for a very, very long time, and nothing is being done, unfortunately. I ended up implementing a 30 second timer in HA, triggering it from NR, and waiting for 60 sec. If nothing happens, I just restart NR (via a webhook).

bogorad avatar Jun 27 '24 16:06 bogorad

The problem keeps coming back even though I am still on nodered 4.0.0. I enabled the heart beat option in the addon which does help somewhat. I can't put my finger on the problem. The problems are also random in terms of timing.

schwickster avatar Jul 11 '24 22:07 schwickster

Hello, i want to join in to this problem. For me it is the same issue but i don't know if the problem came up with node-red 4.0 because i started just some weeks ago with that plugin and use homeassistant just for one device.

It seems to me that restarting node-red helps BUT only ~18-23 hours. Than reconnects come back sometimes 10-20 per second. In my case i get confused about high CPU-load on my server which brings me to take a look at the cpu-load of node-red and home assistant to check if the problem is back again.

Is there a way to get more detailed logs for that plugin?

Bond246 avatar Aug 05 '24 18:08 Bond246

so I ended up with this dirty little fix:

  1. in HA I created a helper of the type button.
  2. in HA I created an automation: every 10 seconds press input button.
  3. in NR I wait 60 sec since the button was last "pressed" and restart NR via a http-call to a webhook running on host.

too bad the author doesn't consider this to be a problem.

image image image

bogorad avatar Aug 05 '24 18:08 bogorad

Hello,

i have the same issue here ... after a restart it works for a time ...

17 Aug 15:54:56 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:54:56 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:54:58 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:54:58 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:54:58 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:00 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:00 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:01 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:03 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:03 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:03 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:05 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:05 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:05 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:07 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:08 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:08 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:10 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:10 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:10 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:12 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:12 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:13 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:15 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:15 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:15 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:17 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123 17 Aug 15:55:17 - [info] [server:Home Assistant] Connection closed to https://192.168.101.100:8123 17 Aug 15:55:17 - [info] [server:Home Assistant] Connecting to https://192.168.101.100:8123 17 Aug 15:55:19 - [info] [server:Home Assistant] Connected to https://192.168.101.100:8123

HendrikKirsch avatar Aug 17 '24 13:08 HendrikKirsch

try my hack https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues/1425#issuecomment-2269688113

bogorad avatar Aug 17 '24 15:08 bogorad

Hello,

I use a new long time token at this time and the connection is stable... for 4 days... after that the connection is lose...

HendrikKirsch avatar Aug 19 '24 07:08 HendrikKirsch

Does this problem also cause a permanently high CPU load for you when you use the Node-RED addon in HAOS?

I have noticed a sluggish behavior of Node-RED for some time now and have now been able to identify this node as the cause by exclusion.

The addon's info page permanently shows me ~25% CPU load. My system is the current HAOS on an Odroid-M1 (arm64) with 8 GB RAM. All other addons work without any problems.

Since several new connections to the server were also displayed in the log, I thought there might be a connection with your problem.

Screenshot 2024-09-09 090619

Screenshot 2024-09-09 090538

steff75 avatar Sep 09 '24 15:09 steff75

It could cause high CPU usage if node-red is constantly trying to re-connect. However, I don't use nr-addon, so can't be sure.

bogorad avatar Sep 09 '24 17:09 bogorad

It would be helpful, if the node would then write something in the debug sidebar or in the container log.

steff75 avatar Sep 09 '24 17:09 steff75

haha, it's been requested many times. better yet, it'd be great if it failed, and we could use the catch node ;)

bogorad avatar Sep 09 '24 17:09 bogorad

Try updating to the latest release, v0.47.0, and see if it resolves the issue.

zachowj avatar Oct 07 '24 20:10 zachowj

seems to be working! thanks!

bogorad avatar Oct 15 '24 20:10 bogorad

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 23 '24 06:12 github-actions[bot]