iosreact-nativebonjourzeroconfnsnetservice

NSNetServicesErrorCode = "-72008" error on xcode ios


I keep getting this error no matter what changes I make

[Error: {
    NSNetServicesErrorCode = "-72008";
    NSNetServicesErrorDomain = 10;
}]

I have this in my info.plist

    <key>NSLocalNetworkUsageDescription</key>
    <string>App would like to use network discovery</string>
    <key>NSBonjourServices</key>
    <array>
        <string>_myservice._tcp.</string>
    </array>

and I'm using the latest version of react-native-zeroconf

import Zeroconf             from 'react-native-zeroconf';

this.zeroconf = new Zeroconf ();

this.zeroconf.scan ('_myservice', '_tcp', 'local');
    "react-native": "0.71.4",
    "react-native-zeroconf": "^0.13.8",

I even tried this in my info.plist (removed the last period)

    <key>NSLocalNetworkUsageDescription</key>
    <string>App would like to use network discovery</string>
    <key>NSBonjourServices</key>
    <array>
        <string>_myservice._tcp</string>
    </array>

I verified that i have this service running

dns-sd -B _myservice._tcp

Browsing for _myservice._tcp
DATE: ---Sat 21 Dec 2024---
 0:20:38.960  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
 0:20:38.961  Add        2  13 local.               _myservice._tcp.      correct_name

So why am I still getting the -72008 error?


Solution

  • I got this to work by changing the scan params to

    this.zeroconf.scan ('myservice', 'tcp', 'local');