Connection closed to undefined - Constant connection loop

I’ve spent multiple hours on this and still cannot figure out what exactly is going on. Completely out of ideas.

**

Issue: Node Red cannot seem to connect to Home Assistant server. I cannot use get current state node and also get Entity could not be found in cache for entity_id for errors everywhere.

**



Attempt 1: If 'I use the Home Assistant Add-On' is checked, I see this in the node-red logs

This 3 lines are repeated every few seconds. It seems that it keep going to in a boot loop.

**
[info] [server:Home Assistant] Connection closed to undefined
[info] [server:Home Assistant] Connecting to undefined
[info] [server:Home Assistant] Connected to undefined
** 

Also, I get Entity could not be found in cache for entity_id errors. Essentially I cannot use get current state node too. Node-Red cannot connect to HA.



Attempt 2: If I set my server node base url as http://192.168.7.9:8123 pointing to my server, everything seems to work but my debug output is completely empty/blank always. (websocket issue?)

Also, looking at trace I see comms.open and comms.close repeated every 2 seconds.

**
[trace] comms.open sPEInLHfC9H+AonpYDtQoHlCOh1SGWtbEby+ljbf40E=
[trace] comms.close sPEInLHfC9H+AonpYDtQoHlCOh1SGWtbEby+ljbf40E=
** 


I tried

  • completely reinstall Node-Red (deleting node-red folder before installing), still same issues
  • change from ngnix proxy to ngnix proxy manager and made sure websocket is enabled


My setup (everything is updated as of today):

  • core-2021.12.7
  • supervisor-2021.12.2
  • duckdns add-on
  • ngnix proxy manager add-on
  • node-red 10.2.2 add-on
  • Zigbee2mqtt 1.18.1-1

Other relevant info in my configuration.yaml

homeassistant:
  external_url: "https://xxx.duckdns.org"
  internal_url: "http://homeassistant.local:8123"
http:
  use_x_forwarded_for: true #Required for Home Assistant versions 2021.7 and later 
  trusted_proxies: #Required for Home Assistant versions 2021.7 and later 
    - 172.30.32.0/23 #somehow my setup generated this internal docker ip address (got from `network info` in cli)
    - 172.30.33.0/24 #Required for Home Assistant versions 2021.7 and later 

I am out of ideas what else to try and what is the issue.

what does a flow look like where this issue is occurring? Is the flow running before NR has had a change to connect to HA?

I think I may have finally figure it out after 12 hours. I think I had too many entities which killed websocket continuously with MESSAGE SIZE EXCEEDED. See: Client exceeded max pending messages [2]: 512 · Issue #153 · zachowj/node-red-contrib-home-assistant-websocket · GitHub

I disabled a ton of entities and finally things seem to be working. Will monitor.