Node Red very slow

Hey there,

i’ve been using Node Red for a while now and never had any issues with it.
But since a week or 2 everything is very slow, for example i have multiple flows where a switch triggers a “call service” node and this worked perfect for several months, but now when i trigger the switch nothing happens for several minutes en then the “call service” node begins. When i open Node Red and see what happens i notice that there is a delay when the “fire event” node changes state (10 to 20 seconds) and when it does change the “call service” node keeps at state “sending” . Where before it was “sending” for like 1 second now it keeps sending for 1 minute or so.

I’m no expert so excuse me if i’m not clear with info,but here is what i have:

Node-RED ; Current version: 9.2.0
Core ;core-2021.6.6
Supervisor ; -2021.06.8
Docker ; 20.10.7

When i look at the logs i sometimes see ;

7 Jul 15:22:26 - [warn] Communication send error: Error: WebSocket is not open: readyState 2 (CLOSING)
7 Jul 15:22:32 - [warn] Communication send error: Error: WebSocket is not open: readyState 3 (CLOSED)

I have searched and googled everything i could but like i said , i’m not that big of an expert so i don’t know what to do. It’s driving me (and me wifi :slight_smile: ) crazy but everything keeps crashing, my blinds go up and down, window shutters don’t go down anymore…

please help me

i’ve had debugging on and had this message minute after minute ;

8 Jul 10:32:05 - [info] [server:Home Assistant] Connection closed to http://supervisor/core
8 Jul 10:32:10 - [info] [server:Home Assistant] Connecting to http://supervisor/core

anyone?

What about the rest of the system, memory free? HD free? size of data base? You could install glances from the addon store see what is going on system wise, is it only nodered or is the whole system getting bogged down.

Thanks for your reply,
System using not more than 25% CPU and 10 % RAM, everything else working well. When i turn on my blinds on the lovelace screen it goes direct up or down,when i deploy it in NodeRed it keeps sending the “call service” node and after about 10 seconds it deploys where in the past this was never the case. The problem seems in the connection between HA and NR…somethings responses are super fast with no errors, and a couple times a time the delays are more then a minute. Sounds stupid i know but i have allot of flows that ineract with eachother so when there is a delay in the first flow all the rest keeps hanging and nothing works.

Is it always the same flow/s? Maybe there is something is wrong, there have been changes to the HA nodes. If that’s the case post what has the problem.

Also check the drop down ha server list in a call service node. Are there multiple copies?

It’s not always thesame flow, even when i make a new simpel flow with 1 call service node and an inject node, the call service node keeps sending for a while. Just tested it again and for the moment it works like a charm, no delays what so ever. I only have 1 server in the server list. I checked the box “i have the HA addon” . I’ve allready unchecked the box with a 5 second delay cause i allready read that it could be a solution but no luck so far. Could it be that when i deploy a modified flow, everything is reconnected again? I always select deploy modified flows,not all flows but seems like when i modify a flow it is the worst (honestly i keep searching for a constant but don’t know it anymore)

I think you next steps would be to roll back to a working snapshot of nodered. Then ultimately if that doesn’t fix it, remove and reinstall.

The first time i noticed something was wrong was when i updated home assistant to supervisor-2021.06.8
My first thought was that it was the update causing this issues so i went back with a snapshot from the day before and i thought that it was ok then. But it kept coming back so eventually i updated everything and it worke after a restart so i was glad ant thought i was ok…but after a day or so it came back :frowning:
Yesterday i completly removed node Red, including all the maps of NodeRed and did a clean re-install and imported my flows again after i restarted NodeRed. But i still have thesame problem.
I really have the idea that when i modify flows and deploy with “only deploy nodes that have changed” it occours, i just modified a node and deploy it and had this in my NR logs :

9 Jul 07:38:08 - [info] Started modified nodes
9 Jul 07:38:11 - [warn] Communication send error: Error: WebSocket is not open: readyState 3 (CLOSED)

I don’t know if this error causes the delays i have, but it is the only thing that seems not right in the logs. But i can’t believe that modifying 1 node causes all flows to be unresponsive (the first time?) to be used. I can only look back in the logs for a short period of time, but it seems the only time the websocket error occours is when i deploy.

Just tested again and when i call a service with a time stamp it goes well, “sending” status is only 1 second and light goes on inmediatly, so for now i’m happy but in the past it was fine to but after a certain time it was corrupt again ( i was working in node red before and was testing when i noticed the delays i think).

So my first thought now is that when i add new flows or modify excisting flows i get these errors,is this possible? I know it sounds strange but i really don’t know what else is the constant factor.

Just modifies another flow and deployed it and this was in my log:

9 Jul 08:35:24 - [info] Started modified nodes
9 Jul 08:35:31 - [warn] Communication send error: Error: WebSocket is not open: readyState 3 (CLOSED)

could this cause the strange behavior sometimes?

Are you using direct access? ie your home assistant IP with 1880 instead of 8123? If not the web socket error is probably from the reloading of the browser. Use the direct port and see if it’s still there.

If it is a web socket error it’s probably related to the debug loss problem. Read through the thread the only solution (th00mas88 comment) is to make the auth connection manually.

Which means going through the remove process again. Then updating all the nodes.

I’m accessing home assistant on 192.xxx.x.xxx.xxx:8123 and from there on i start NR from the sidebar.
Then when i modify a flow and deploy it i get a websocket error.

Interesstingly enough when i,as you mentioned open node red from 192.xxx.x.xxx.xxx:1880 and the deploy a modified flow i have not websocket error.
So thanks for the heads up, i think now i can conclude that the websocket error is not the cause of the delays,right?
I read the post you mentioned and if i understand it right, it’s about having no debugging,right? i do have debugging (but also the websocket error), only sometimes very slow connection to HA that causes very big delays and flows not working, or am i seeing this wrong?

I do see that certain actions sometimes are beeing executed multiple times like this:

9 Jul 10:34:17 - [debug] [api-call-service:boolean lamellen oosten sluiten] Calling Service: input_boolean:turn_on – {}
9 Jul 10:34:18 - [debug] [api-call-service:boolean lamellen oosten sluiten] Calling Service: input_boolean:turn_on – {}
9 Jul 10:34:18 - [debug] [api-call-service:boolean lamellen oosten open UIT] Calling Service: input_boolean:turn_off – {}
9 Jul 10:34:19 - [debug] [api-call-service:boolean lamellen oosten open UIT] Calling Service: input_boolean:turn_off – {}

I think that this action was active for 2 seconds and instead of do it once it was beeing deployed 4 times because the call service status is sending for a while. Sometimes it’s beeing deployed for more then 10 times if the “call service” status is “sending” for a couple of seconds. I allready hade a delay node in front of it that only lets 1 signal passes per 5 seconds and drops all remaining signals that possibly would arrive , so i’m sure i do not trigger the call service node multiple times.

The biggest issue i’m having right now is that if there is a multiple “call service” beeing deployed, because of the node is beeing send for a couple of seconds, my blinds are recieving a couple of times the “go down” order, causing them to go down,stop,go down,stop,… and this is very frustrating.
I do have i physical switch next to the window, en when i press it to go down, it sometimes takes up to a minute when this action is beeing seen in Node Red in the “trigger state” node.
This occours a couple times a day. Restarting NR or HA sometimes helps, but not always, so thats’t not the sulution either.

Here an example that i’ve set up to test

When i turn on my kitchen light, it instantly goes on, but the node keeps sending for 5 seconds.
The poll state is set on polling every second, and even when the light is on for several seconds it keeps saying it is off until the node stops sending.
in this case it’s no big deal, but i have several flow that turn on a boolean when for example sun intensity is to high to close my blinds. When the first boolean is turned on another flow looks at the state of the first boolean to turn off or on another boolean and so on…
To make a long story short :slight_smile: These flows use to work perfect,but now i see blinds not going down or up because of these delays.Not shure what causes them now :woozy_face:

try shutting down all you pages, double click on the top tab, sidebar opens, bottom left corner, disable. Then on a new page make another server connection, this time manually with a long lived token. Then create flows and see if you can replicate the problem.

There’s been a few odd behavior problems related to the no debugging problem. The debugging is a symptom and not the cause. So your problem may just be an extension.

Yesterday i tried to disable one of my pages to see what it did with my CPU usage of NodeRed, it went from 25,6% to 25,3% so no big difference. When i enabled the page back all my entity’s i’ve created in Node Red on that specific page where gone and re-registrated, this was just the page with calculations to calculate my energy consumption , and had allot of errors and took some time to get them all working again :slight_smile: :crazy_face:

I’ve just created a new page and added a server with a life-time token,this is the result :

The call service with the server with add on keeps sending,while the server with long-life token reacts as it should, so you’re right about that!!!

So my thought is that i have to move all my flows that are on the server with add-on to the server with token,right? Does this mean i have to uninstall NodeRed again to reinstall?
I just looked i have more than 2000 entities currently that are on the server with add-on so manually move them one by one is a very time consuming job i thing :slight_smile:

Thanks allready!!!

I ended up just modifying my existing server to server with token,restarted HA en so far so good.
Let’s hope it stays this way :grimacing:

This did not work :pensive:

I have deleted NodeRed, completly, removed all folders and did a re install of NodeRed.
Set server with token and imported my flows and manually changed server (2022 times :thinking:) to the new server i had set up with token. Spend 3h doing that to find out it was even worse now :woozy_face: The debugging keeps showing ;

disconnecte from server 192.168.x.xxx:8123
connected to server 192.168.x.xxx:8123
disconnecte from server 192.168.x.xxx:8123
connected to server 192.168.x.xxx:8123

wich resulted in states constant beeing disconected en connected again.
Finally i changed the server back to “i use the add-on” , it was better for 5 minutes but just saw that it keeps “sending” again, so no luck there :rage:

Don’t know what to do anymore , please help :fearful:

I’m out of suggestions. I’d say file an issue but if they can’t reproduce the error, it’s difficult to fix. You could try the discord channel. A heads up, etiquette is very important there. You could also search the nodered forums for lag/delay in general.

I really appreciate your help, i’ve been struggling with this for 3 whole days now. Yesterday i installed NR again and imported all my flows back with the server add-on (token really was worse all of a sudden).
I’ve noticed the CPU usage of NR was reduced from 25,6% to 18,9% the last time i re installed NR without changing any flows, this gave me hope :slight_smile:
I took a critical look at all my flows and changed some poll states with an interval of 1 second to trigger states, i think i’ve changed about 50 poll states to tigger states and saw my CPU usage is now about 16-17%…
Not jumping to conclusions yet but since yesterday everything works fine again, just hope it stays this way. :pray:
Seems like the higher CPU usage caused the lags, but no idea why i dropped after reinstalled it twice now.

Still have the websocket error in the logs everytime i open node red, but if it doesn’t effect the operation i’ll just wait untill another update will fix it i hope.

Have you resolved this issue?
What version is your NR?

I have a similar situation, where NR receives changes from HA probably 3-5s later.

I recently upgraded to NR 10.0.0 and I am not sure if it is related. Planning to reinstall NR and see if the problem goes away