Skip to content

Add native DNS-SD advertiser for macOS (no UDP 5353 bind) - #213

Open
kgoderis wants to merge 1 commit into
hap-java:masterfrom
kgoderis:feature/native-dnssd-advertiser
Open

kgoderis wants to merge 1 commit into
hap-java:masterfrom
kgoderis:feature/native-dnssd-advertiser

Conversation

@kgoderis

@kgoderis kgoderis commented Oct 22, 2026 •

Copy link
Copy Markdown

What

Adds a pluggable HomekitAdvertiser and a native DNS-SD / Bonjour implementation (DnssdHomekitAdvertiser) that registers _hap._tcp via DNSServiceRegister (JNA) without binding UDP 5353. Existing JmDNS constructors keep working. Factories live on HomekitAdvertisers (nativeDnssd(), auto(...), etc.). See docs/NATIVE_DNSSD.md.

Why

Fixes #212. On macOS, mDNSResponder owns UDP 5353, so a dedicated JmDNS advertiser fails with “Address already in use” / “no suitable mDNS” and Home never discovers the accessory.

Compatibility

  • Additive API: new HomekitServer / HomekitRoot overloads that take HomekitAdvertiser.
  • Existing InetAddress / JmDNS constructors unchanged.
  • New runtime dependency: net.java.dev.jna:jna (5.14.0) for the native path only. JmDNS-only users still pull the jar transitively unless they exclude it; native symbols come from macOS libSystem or Avahi libdns_sd.

Testing

  • mvn -B package on JDK 11: 34 tests, 0 failures (CI-equivalent).
  • Unit tests for TXT encoding, mocked DNSSD register/re-register/stop, factory probe.
  • Live macOS check: advertised hap-java-fake-demo; dns-sd -B / -L / -Z showed PTR/SRV/TXT; Java process had no UDP 5353 socket.

Checklist

@kgoderis
kgoderis force-pushed the feature/native-dnssd-advertiser branch from 175f81a to fb1842f Compare October 22, 2026 19:12
Pluggable HomekitAdvertiser lets callers use DnssdHomekitAdvertiser (JNA
DNSServiceRegister) instead of JmDNS when mDNSResponder owns UDP 5353.
Fixes hap-java#212.
@kgoderis

Copy link
Copy Markdown
Author

@yfre Eugen, this PR is necessary for a downstream fix in openHab openhab/openhab-addons#22013

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: JmDNS advertiser cannot bind UDP 5353 (mDNSResponder); need native DNS-SD path

1 participant