mDNS Resolver and mDNS Responder cannot be used simultaneously due to both attempting to bind port 5353 #72553
Labels
area: Networking
bug
The issue is a bug, or the PR is fixing a bug
priority: medium
Medium impact/importance bug
Describe the bug
The Networking subsystem has support for mDNS, through the mDNS Resolver (part of more general DNS Resolver) and the mDNS Repsonder (specifically mDNS). Each of these work individually, but the two cannot be used together. This is due to both Resolver and Responder trying to bind the same port 5353 independently. Whichever one attempts the bind after the other (mDNS Responder) fails as the port is already in use.
It should be possible to enble the mDNS Resolver and mDNS Responder simultaneously.
What target platform are you using?
What have you tried to diagnose or workaround this issue?
Enabling logging for mDNS Responder (
CONFIG_MDNS_RESPONDER_LOG_LEVEL_DBG
) shows:<err> net_ctx: Port 5353 is in use!
<dbg> net_mdns_responder: bind_ctx: (main): Cannot bind to mDNS IPv4 port (-112)
Debugging the networking subsystem shows that during initialisation:
dns_init_solver()
->dns_resolve_init_default()
->dns_resolve_init()
->dns_resolve_init_locked()
->net_context_bind()
)mdns_responder_init()
->init_listener()
->bind_ctx()
->net_context_bind()
) but fails with-EADDRINUSE
(112) as the port is already bound.To Reproduce
Steps to reproduce the behavior:
cd zephyrproject
west build -b <BOARD> -d build_mdns_sample zephyr/samples/net/mdns_responder/ -- -DCONFIG_DNS_RESOLVER=y -DCONFIG_MDNS_RESOLVER=y -DCONFIG_DNS_SERVER_IP_ADDRESSES=y -DCONFIG_CONSOLE=y -DCONFIG_LOG=y -DCONFIG_MDNS_RESPONDER_LOG_LEVEL_DBG=y
(plus any options needed for logging backend)Expected behavior
mDNS Resolver and mDNS Responder should be able to co-exist. The port should probably only be bound once, with incoming traffic dispatched to Resolver or Responder handlers as appropriate, rather than the two subsystems existing independently and both attempting to bind the port.
Impact
Showstopper for applications requiring full mDNS functionality (Resolver and Responder)
Logs and console output
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: