NRCHKB / node-red-contrib-unifi-os

Nodes to access UniFi data using endpoints and websockets
Apache License 2.0
28 stars 1 forks source link

RAM Usage, it seems each call is not closed, multiple TCP connections open #60

Open Matej-Liska opened 1 year ago

Matej-Liska commented 1 year ago

Hi, I have found out there is some issue with unifi-request node (after updating UDMPro to latest version), which causes high RAM usage after some time (12hrs?).

I have this simple flow where which can be seen on screenshot below. Basicaly it GETs, JSON data from cameras (3x), every 2 seconds (motion detection). I did a bit of research and found out that it seems each call of this node is maybe not being closed - meaning there is a huge amout of opened TCP connections after some time. Please see NETSAT output to get an idea. I think this is root cause.

In the past before UDM update it was allright, but now I had to disable it because it lagged whole NR after some time (high RAM, high CPU).

System info: RPi4 2GB UDM Pro v3.1.15 Node-red 2.2.2. node-red-contrib-unifi-os 0.9.0

Please could you look into it? Thanks & keep up the good work 🥇 Nodes NETSTAT opened connections

crxporter commented 1 year ago

@marcus-j-davies have you seen this one? Are you bored this weekend?

hjuhlin commented 1 year ago

I have the same error:

I have gotten a lot of enobufs (WSAENOBUFS) errors in Windows lately. After a lot of searching I did find a command (netstat -ab) to view open connections to find the problem.

When running netstat -ab I did find out that node-red was the problem for all of my enobufs problems. And mostly Unifi connections (and some others).

So I have MANY connections that are not closed to my UMD-Pro [node.exe] TCP 192.168.1.4:64755 unifi:https ESTABLISHED

After running node-red for 12 hours I have around 2300 open connections in node-red and around 2/3 of them are to unifi. The other 1/3 are to Shelly components.

The command netstat -nao | find /i "estab" /c shows the total sum of connections that are established and that number just keeps growing until I restart node-red.