Hi,
my HA installation of 2021.9.3 in a venv dies after few hours with a ‘too many open files’ error. Reason for this is that the python3.9 process for HA creates an ever growing number of UDP connections.
The command
netstat -paee | grep homeassistant
gives many of these lines:
udp 0 0 0.0.0.0:44280 0.0.0.0:* homeassistant 48060835 435795/python3.9
udp 0 0 0.0.0.0:40271 0.0.0.0:* homeassistant 48070816 435795/python3.9
udp 0 0 0.0.0.0:56722 0.0.0.0:* homeassistant 48001914 435795/python3.9
udp 0 0 0.0.0.0:44491 0.0.0.0:* homeassistant 48060836 435795/python3.9
udp 0 0 0.0.0.0:58830 0.0.0.0:* homeassistant 47967793 435795/python3.9
udp 0 0 0.0.0.0:34372 0.0.0.0:* homeassistant 48232404 435795/python3.9
If I count these lines over time with running this command every 60 s:
netstat -paee | grep homeassistant | grep -i udp | wc -l
I get for example
Wed 08 Sep 2021 06:02:01 PM CEST, 69
Wed 08 Sep 2021 06:03:01 PM CEST, 69
Wed 08 Sep 2021 06:04:01 PM CEST, 71
Wed 08 Sep 2021 06:05:01 PM CEST, 73
Wed 08 Sep 2021 06:06:01 PM CEST, 73
Wed 08 Sep 2021 06:07:01 PM CEST, 75
Wed 08 Sep 2021 06:08:01 PM CEST, 77
Wed 08 Sep 2021 06:09:01 PM CEST, 79
Wed 08 Sep 2021 06:10:01 PM CEST, 79
Wed 08 Sep 2021 06:11:01 PM CEST, 81
Wed 08 Sep 2021 06:12:01 PM CEST, 83
I.e. two new UDP connections every ca. 60 s. I tried to find out what is causing this using strace with
strace -s 10000 -e trace=network -fp 435795 2>&1 | grep UDP
I get whenever the above list grows by 2 UDP connections, i.e. every ca. 60 s:
[pid 435795] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 46
[pid 435795] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 47
and another 60 s later:
[pid 435795] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 45
[pid 435795] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 48
Showing more lines with grep -a3, I get:
10235166:[pid 435795] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP) = 68
10235238-[pid 435795] bind(68, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
10235339-[pid 435795] getsockname(68, {sa_family=AF_INET, sin_port=htons(57646), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
10235453-[pid 435795] getpeername(68, 0x7ffd4d4290a0, [16]) = -1 ENOTCONN (Transport endpoint is not connected)
10235556-[pid 435795] getsockname(68, {sa_family=AF_INET, sin_port=htons(57646), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
which does not help me much.
Do you have an idea how I could find out which python module of HA causes this continuous increase of open UDP connections?
Best regards,
Frank