node-red-contrib-home-assistant-websocket: Intermittent "connection closed"; shows in log, does not generate an error in Node-red

Describe the bug

Suddenly I’m getting these messages in my NR log:

26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connecting to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connected to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connection closed to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connecting to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connected to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connection closed to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connecting to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connected to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connection closed to http://localhost:8123
26 Dec 20:24:58 - [info] [server:ha-bruc-pi] Connecting to http://localhost:8123

Restarting HA does not help. Restarting Node-red helps, but there’s no error generated in NR, so there’s no way of knowing that something is wrong.

To Reproduce

No response

Expected behavior

No response

Screenshots

No response

Example Flow

No response

Environment Information

Version:

Home Assistant version: 2023.12.3 Companion version:

Node-RED version: 3.1.3 Docker: yes Add-on: no

Node.js version: OS:

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 25 (6 by maintainers)

Most upvoted comments

image

Enabling heartbeat in node red (under edit Server node) seems to be a workaround for the short term

Isn’t this enabled by default with the add-on?

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

sure. I simplified it. now there’s an “automation” in HA to trigger timer every 30 seconds, and all I have to do in NR is to wait for the timer to stop “starting” for 1 min.

image image image

https://pastebin.com/V16vChpA

On my end the culprit was a timed process which ate all my cpu power (as I am temporarily running on a limited rpi), which was not interruptible which lead to NR disconnecting. I found it my enabling debug logging and carefully watching what happened every 120 sec - as the process spat out huge logs (which also contributed to “locking up” HA). I removed the offending process - temporarily - and everything is back to normal.

Browsing through my websocket debug log on HA I find these two lines which correlates with when Nodered disconnects:

2023-12-29 23:21:02.813 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [546908513984] nodered from 172.17.0.7: Writer done
2023-12-29 23:21:02.813 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [546908513984] nodered from 172.17.0.7: Disconnected