-
Notifications
You must be signed in to change notification settings - Fork 103
Android Implementations
On Android you choose the backend per call with implType:
NSD (default) |
DNSSD |
|
|---|---|---|
| Engine | Android's NsdManager
|
mDNSResponder embedded in the library |
| Depends on | The system NSD service, varies by device | Only the library's native code |
mDNS host name in host
|
🟡 | ✅ |
| All addresses | 🟡 | ✅ |
| TXT order kept when publishing | 🟡 | ✅ |
Updates re-emitted as resolved
|
🟡 | ❌ |
| Concurrent resolves | 🟡 | ✅ |
| Error domain | 'NsdManager' |
'DNSSD' |
The embedded mDNSResponder comes from Discord's RxDNSSD fork.
import Zeroconf, { ImplType } from 'react-native-zeroconf'
zeroconf.scan({ type: 'http', implType: ImplType.DNSSD })
zeroconf.publishService({ type: 'http', protocol: 'tcp', name: 'MyServer', port: 8080, implType: ImplType.DNSSD })On iOS, macOS and tvOS implType is ignored.
Start with NSD if you target recent Android versions and it finds your devices.
Switch to DNSSD when:
-
NSDfinds nothing, or stops finding services after a few scans (common on some OEM builds), - you need the
hostname on Android versions before 16, - you publish TXT records whose order matters,
- you discover printers (
pdl-datastream,ipp) andNSDmisses them.
Native code in the library is built with 16 KB page alignment, which Google Play requires for apps targeting Android 15+.
-
One scan per instance. Calling
scan()with a differentimplTypeon the same instance moves that instance's scan to the other implementation. Separate instances can scan at the same time, andNSDandDNSSDscans can run concurrently. -
stop()without arguments stops the implementation the instance's lastscan()used. -
unpublishService(name)withoutimplTypeuses the implementation the service was published with. - After
stop(), giveDNSSDa short delay (around 500 ms) before scanning again.
These are platform issues that affect every mDNS library using NsdManager:
- discovery silently stops after a while, after screen lock or when backgrounded,
- a service is found but its resolve fails,
- multicast is throttled by battery optimizations on some manufacturers (Samsung, Xiaomi, Huawei...),
- network changes (Wi-Fi reconnect, band switch, mesh handoff, VPN) break discovery.
Workarounds: use DNSSD, stop the scan when the app goes to the background and scan again when it becomes active, and retry a scan that returned nothing. See Troubleshooting and FAQ.
Documentation for react-native-zeroconf 0.17. Found a mistake? Open an issue. | Home | API Reference | Troubleshooting