Homekit integration: multiple binds to 0.0.0.0 on port 5353

Hello guys and girls!

I’m having an issue since I enabled the homekit component in Home Assistant, version 0.101.1. Maybe some of you could help a fellow tinkerer out!

I’m running HA on docker, with network_mode: host because I’ve also an Aqara gateway, that needs this if running on docker.

The issue is that HA binds itself to multiple 0.0.0.0 addresses on port 5353 for, I believe, multicast discovery, but the wrong “interfaces” never consume the udp packets, so these ends up saturating the UDP sockets memory, and then UDP packets errors start popping up.
Here an example from netstat -ulpn, as you can see the Recv-Q backlog is ramping up, and this is just after 20 minutes of HA running.

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4568832 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 0 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 4603072 0 0.0.0.0:5353 0.0.0.0:* homeassistant
udp 0 0 0.0.0.0:5353 0.0.0.0:* homeassistant

If I just expose port 8123 on docker and remove network_mode: host, then the issue isn’t present, but I can’t afford to lose all the sensors from Aqara, so this is not an option.

This issue is similar to Issue#20095 (zeroconf on multiple interfaces issue · Issue #20095 · home-assistant/core · GitHub).

Has anyone ever had this problem and found a way to solve it?
Thanks!

Bump.

I’ve reverted for a file to a docker install without --net host, but it’s excruciatingly painful, as some integrations - even with the right ports open - refuse to work (e.g. playstation 4, lg tv, etc)

I find it impossible that no one else is having this issue: my only explanation is that no one is using a tool like netdata that shows the error to the user.

Happy to be corrected though :slight_smile:

zeroconf_default_interface was recently added

Hi @bdraco,

Thanks for the heads up. I recently filed a bug request for zeroconf, and was told that your fix (option for default interface) is a possible candidate to solve my issue.

I’d like to take advantage of your expertise though: I recently updated the homekit configuration with the new option, and I also tried to disable zeroconf and discovery, but home assistant keeps binding to multiple interfaces. Do you have suggestions on how I could pinpoint the issue?
I will test the “default interface” option on zeroconf as soon as it leaves the dev/beta branch (I don’t know if using tag “dev” is enough even for the docker version), but I’m still dubious that it will be enough, as it seems there are 3 different components that use multicast and start opening these sockets. Culprit is always home assistant.
Excerpt below

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp   1351040      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1390208      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp   1807552      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           21534/python3

Do you think that the new option will be enough to stop this behaviour?

Thanks for your time!

You’ll need to set the option for both homekit and zeroconf since they both use Zeroconf which by default binds to all interfaces. When the default interface option is set Zeroconf should only bind to the default interface.

1 Like

Thanks! I hope that will solve the issue! I’ll try to spin up the container with the dev branch and see if I can test it.