Skip to content

[homekit] Use native DNS-SD when JmDNS cannot bind UDP 5353 - #22013

Draft
kgoderis wants to merge 2 commits into
openhab:mainfrom
kgoderis:feature/homekit-native-dnssd-hap
Draft

kgoderis wants to merge 2 commits into
openhab:mainfrom
kgoderis:feature/homekit-native-dnssd-hap

Conversation

@kgoderis

@kgoderis kgoderis commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Bugfix / improvement for HomeKit bridge advertising on hosts where a system mDNS daemon already owns UDP 5353.

When useOHmDNS does not yield a matching shared JmDNS client (or when creating a dedicated advertiser), the add-on previously fell back to HAP-Java's JmDNS path, which binds UDP 5353. On macOS, mDNSResponder owns that port exclusively; the bind fails (Address already in use / "no suitable mDNS") and Apple Home never discovers _hap._tcp even though the HAP TCP listener is up. The same class of conflict appears with Avahi and other system responders.

This change prefers HAP-Java's native DNS-SD / Bonjour advertiser (HomekitAdvertisers.nativeDnssd() via DNSServiceRegister / JNA) when that path is supported, so _hap._tcp is published without binding 5353. Existing useOHmDNS=true sharing of openHAB's JmDNS is unchanged when a suitable client is found.

Depends on the upstream HAP-Java PR (not yet merged/released):

Until that lands on Maven Central as a release (currently hap 2.0.10-SNAPSHOT + embedded JNA 5.14.0), this PR is a draft. After the HAP-Java release, the pom will be bumped to the released version and the draft can leave WIP.

Resolves #22012

Related reports (mDNSResponder / UDP 5353 / _hap._tcp advertising)

GitHub

Community

User impact

  • No configuration change required for the common macOS case (useOHmDNS=false): native DNS-SD is selected automatically when supported.
  • useOHmDNS=true continues to prefer openHAB's shared JmDNS when a matching interface client exists.
  • Adds a runtime dependency on JNA (embedded in the HomeKit bundle) for the native path.

Compliance

  • EPL-2.0 headers preserved
  • Signed-off-by: Karel Goderis <karel.goderis@me.com> on all commits (DCO)
  • Spotless check passed on org.openhab.io.homekit
  • NOTICE updated for JNA
  • README: useOHmDNS documents the native DNS-SD fallback

Testing

Verified on openHAB 5.3.0.M3 (native macOS Apple Silicon):

  • With this jar and useOHmDNS=false, logs show native DNS-SD registration (no UDP 5353 bind by the JVM)
  • dns-sd -B _hap._tcp lists the openHAB bridge instance(s)
  • Pair-setup / Home discovery proceeds past Bonjour advertisement

CI of this draft will not resolve hap 2.0.10-SNAPSHOT until HAP-Java #213 is released; please treat merge readiness as blocked on that upstream release.

Prefer HAP-Java HomekitAdvertisers.nativeDnssd() instead of a dedicated
JmDNS instance when useOHmDNS finds no matching client (or when creating
a private advertiser). Avoids UDP 5353 bind failures on macOS where
mDNSResponder owns the port.

Bump hap to 2.0.10-SNAPSHOT and embed JNA for DNSServiceRegister.

Signed-off-by: Karel Goderis <karel.goderis@me.com>
Clarify useOHmDNS behaviour when UDP 5353 is owned by a system
responder, note the HAP-Java#213 dependency in the pom, and attribute
JNA in NOTICE.

Signed-off-by: Karel Goderis <karel.goderis@me.com>
@kgoderis kgoderis added bug An unexpected problem or unintended behavior of an add-on enhancement An enhancement or new feature for an existing add-on labels Oct 22, 2026
@lsiepel lsiepel added awaiting external dependency Depends on a new version of an external dependency and removed bug An unexpected problem or unintended behavior of an add-on labels Oct 23, 2026
@lsiepel

lsiepel commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

JFTR #13399 and #21970 are not related, they have a different cause, for #21970 there is a PR pending.

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

Labels

awaiting external dependency Depends on a new version of an external dependency enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[homekit] Prefer native DNS-SD when JmDNS cannot bind UDP 5353 (mDNSResponder / Avahi)

2 participants