← Dev log

networking

mDNS Discovery and Presence

mDNS Discovery and Presence

mDNS lets machines on one network find a service by name with no server. It is a hint about where to connect. It is not proof of identity, and not proof of reachability.

Things that bit:

  • An advert without address records resolves to a .local name with nothing to connect to. Make sure real interface addresses are published.
  • An unchanged service isn't announced again, so "on resolve, send what's queued" runs once. Pending work needs its own periodic redrive.
  • A redrive written as a receive timeout restarts on every unrelated event. Use a deadline.
  • Several interfaces (VPN, container bridges) mean several addresses. Try each one, including the identity check.
  • Multicast is often blocked: container bridges, sandboxes, guest Wi-Fi, host firewalls. Offer pairing and connecting by explicit address.
  • On Windows, an installer may need to add firewall rules for the service.

Presence that held up: probe each known peer over an authenticated connection on an interval (20 s), require two failures before calling it offline, count inbound traffic as contact, and show "recently seen" as its own state. Report separately whether the local service answers and whether its networking works.

Used in: Ferry