You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add ability to specify multicast groups with addresses #1520
Zeroconf assumes that all of the interfaces passed into the library via Zeroconf(interfaces=[<address_0>, <address_1>,...] are able to be bound to. This isn't always the case, for example in a sandboxed environment such as iOS.
In iOS, you are able to bind a socket to 127.0.0.1:5353 but you aren't able to bind to the en0 and pdp_ip0 interfaces on port 5353 because the system daemon is already bound to that. There needs to be a way to configure which addresses are apart of the multicast group that zeroconf builds in.
@bdraco this specifies the interfaces the zeroconf tries to bind to. For the use case that I have I need to add two interfaces to the multicast group while only binding to one of the two.
Apologies about the lack of information, I opened this issue while being on mobile. I will provide more details tomorrow when I have more time :)
I think the best way to articulate the issue is as follows:
On iOS, multicast messages sent to and from the device may not be received unless the device explicitly joins a multicast group on both its local IP and 127.0.0.1. Currently(assume interfaces=[localhost, local_ip]), Zeroconf attempts to bind to port 5353 on both those interfaces which will fail because of iOS sandboxing.
Ideally zeroconf's implementation should support the following:
binding to a specific interface
creating a multicast group for the bound socket consisting of explicitly defined addresses/interfaces
I will likely create the PR for this tomorrow assuming I have time. Are there any contribution guidelines for this project?
Thanks for the additional details. That makes a lot more sense now. It would be helpful if you could also post the log of the exceptions/errors that happen for additional context.
I will likely create the PR for this tomorrow assuming I have time. Are there any contribution guidelines for this project?
Thanks for the additional details. That makes a lot more sense now. It would be helpful if you could also post the log of the exceptions/errors that happen for additional context.
I will likely create the PR for this tomorrow assuming I have time. Are there any contribution guidelines for this project?
I will provide some logs later today, it isn't obvious to be honest that something is wrong. When you bind to all addresses it configures a correct multicast group but wont actually broadcast because of using two unique interfaces(seems to be a posix issue but honestly not sure. I think the kernel doesn't know which interface to use for multicast and decides on neither) while actively using those two interfaces. When you bind to just localhost you wont have any issues other than not receiving anything!
Also keep in mind we eventually need to implement run time reloads to solve home-assistant/core#59553 so any changes should think about that a bit
Is zeroconf technically a home-assistant project or are they just tightly intertwined? Just so I know what to look out for
zeroconf is not a Home Assistant project. It is the largest known user base for this project though and the source of most issue reports. ie. this project's largest customer.
Activity
bdraco commentedon Feb 13, 2025
Check the example in the Home Assistant zeroconf integration on how to specify
bdraco commentedon Feb 13, 2025
https://github.com/home-assistant/core/blob/81cac25bd01c26b8076c938a40a3677d9baf58b0/homeassistant/components/zeroconf/__init__.py#L196
gabearro commentedon Feb 13, 2025
@bdraco this specifies the interfaces the zeroconf tries to bind to. For the use case that I have I need to add two interfaces to the multicast group while only binding to one of the two.
bdraco commentedon Feb 13, 2025
While I'm still not 100% sure what you are asking for,
InterfacesTypedoes allow specifying a list of ip addresses:python-zeroconf/src/zeroconf/_utils/net.py
Line 46 in dba44e4
The code to normalize the choices is at
python-zeroconf/src/zeroconf/_utils/net.py
Line 137 in dba44e4
If you need something more complex we could accept a PR to expand the options.
[-]Unable to specify multicast group addresses[/-][+]Add ability to specify multicast groups with addresses[/+]gabearro commentedon Feb 13, 2025
Apologies about the lack of information, I opened this issue while being on mobile. I will provide more details tomorrow when I have more time :)
I think the best way to articulate the issue is as follows:
On iOS, multicast messages sent to and from the device may not be received unless the device explicitly joins a multicast group on both its local IP and 127.0.0.1. Currently(assume interfaces=[localhost, local_ip]), Zeroconf attempts to bind to port 5353 on both those interfaces which will fail because of iOS sandboxing.
Ideally zeroconf's implementation should support the following:
I will likely create the PR for this tomorrow assuming I have time. Are there any contribution guidelines for this project?
bdraco commentedon Feb 13, 2025
Thanks for the additional details. That makes a lot more sense now. It would be helpful if you could also post the log of the exceptions/errors that happen for additional context.
Commit messages should follow https://www.conventionalcommits.org/en/v1.0.0/ to keep the CI happy, however as long as the title of the PR does it will get squashed in the end anyways.
bdraco commentedon Feb 13, 2025
Also keep in mind we eventually need to implement run time reloads to solve home-assistant/core#59553 so any changes should think about that a bit
gabearro commentedon Feb 13, 2025
Is zeroconf technically a home-assistant project or are they just tightly intertwined? Just so I know what to look out for
gabearro commentedon Feb 13, 2025
I will provide some logs later today, it isn't obvious to be honest that something is wrong. When you bind to all addresses it configures a correct multicast group but wont actually broadcast because of using two unique interfaces(seems to be a posix issue but honestly not sure. I think the kernel doesn't know which interface to use for multicast and decides on neither) while actively using those two interfaces. When you bind to just
localhostyou wont have any issues other than not receiving anything!bdraco commentedon Feb 13, 2025
zeroconf is not a Home Assistant project. It is the largest known user base for this project though and the source of most issue reports. ie. this project's largest customer.
bdraco commentedon May 20, 2026
@bluetoothbot fix
feat: add multicast_addresses to bind/multicast independently
feat: add multicast_addresses to bind/multicast independently
feat: add multicast_addresses to bind/multicast independently
feat: add multicast_addresses to bind/multicast independently