Bonjour discovery not working in iOS (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72008)

I'm currently trying to use an ESP8266, connecting to my home WiFi and starting a mDNS service. Then im trying to discover this service using the bonsoir package in flutter. So far so good. On Android everything works fine, but i want to use the app on the iPhone too.

As far as i understood the information in this video 'developer.apple.com' i need to add this to my info.plist:

<key>NSLocalNetworkUsageDescription</key>
<string>Some understandable text for the user.</string>
<key>NSBonjourServices</key>
<array>
    <string>_http._tcp.</string>
</array>

I wrote a short python script which resolves the service in my network and im getting the following output:

Service ESP8266Control._http._tcp.local. added, service info: ServiceInfo(type='_http._tcp.local.', name='ESP8266Control._http._tcp.local.', addresses=[b'\xc0\xa8\x02\xa0'], port=80, weight=0, priority=0, server='ESP8266Control.local.', properties={b'SN': b'10 - 00001'}, interface_index=None)
Address: ['192.168.2.160']
Port: 80
Service Name: ESP8266Control._http._tcp.local.
Server: ESP8266Control.local.
Properties: {b'SN': b'10 - 00001'}

My flutter app should be correct because on android everything works as expected.

I tried to discover the service in my network by building my app on a mac book for ios. The popup for using the network appears with the defined message "Some understandable text for the user." and i have to confirm the usage of network discovery usage. But when i hit the button in my app to search for my wordclock, the following error is output:

[discovery] [28317] Bonsoir has encountered an error during discovery : ["NSNetServicesErrorCode": -72008, "NSNetServicesErrorDomain": 10] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(discoveryError, Bonsoir has encountered an error during discovery., {NSNetServicesErrorCode: -72008, NSNetServicesErrorDomain: 10}, null)

Is my syntax wrong in my info.plist? I also tried to use this ESP8266Control._http._tcp. and several combinations with .local at the end, with and without the service name and with _http and _tcp seperated as 2 individual entries.

I tried A LOT of combinations, but nothing changes anything.

This is one of the combinations i've tried:

	<array>
		<string>_ESP8266Control._http._tcp</string>
	</array>
	<key>NSLocalNetworkUsageDescription</key>
	<string>Need access to connect with the clock itself.</string>
	<key>NSLocationAlwaysUsageDescription</key>
	<string>This app needs access to location when in the background.</string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string>This app needs access to your location to show nearby networks to connect the Wordclock to.</string>

I would apprecciate help so much, we wasted so much time on this and the apple support told they can't help us...

Best regards MeisterTubi

Replies

Error -72008 is NSNetServicesMissingRequiredConfigurationError which, as you’ve already surmised, means you’re bumping into a local network privacy limit. Normally that means you’ve missed either NSBonjourServices or NSLocalNetworkUsageDescription, but that doesn’t seem to be the case here. The only oddity I see is the value in NSBonjourServices. I recommend that you nix the trailing dot, leaving you with _http._tcp.

If that doesn’t help, my advice is that you build a small native iOS app to see if that works. See Getting Started with Bonjour for instructions on how to do that.

If this works and your third-party library fails, you’ll need to dig into the code for that library.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • Thank you so much! This worked for us! I've put _http._tcp into my info.plist at the NSBonjourServices and now the App connects to my Device successfully!

    I think im in love with you. :D We tried so many things for such a long time now.

    Thanks mate, thanks!

Add a Comment