IOS 17, cannot scan LocalNetworkNSNetServicesErrorCode = "-72007"

Good day. From IOS 17 have a problem with connecting to local ip devices. When i try to scan local network:

 zeroconf.scan('http', 'tcp', 'local.');

i get en error:

Error: { NSNetServicesErrorCode = "-72007"; NSNetServicesErrorDomain = 10; }

I use the react-native-zeroconf libruarry, config the infoPlist with:

"NSBonjourServices": ["_http._tcp"],
"NSLocalNetworkUsageDescription": 
"Allow Turkov application to configure LLC devices"  
"NSAppTransportSecurity": {
          "NSAllowsArbitraryLoads": true,
          "NSExceptionDomains": {
            "localhost": {
              "NSExceptionAllowsInsecureHTTPLoads": true
            }
          }  

And also i get approve sertificate to use multicast from apple team, and apply it in project

"entitlements": {
        "com.apple.developer.networking.multicast": true
      },

Below IOS17 (i tested at 16.6) - all work fine.. Can some one help with that problem?

Answered by DTS Engineer in 801790022

Thanks for all the extra info.

The react-native-zeroconf library utilizes the built-in mDNS stack provided by iOS.

OK. That’s great news. Carrying around your own mDNS implementation is a really bad idea.

But it does mean that I have to come back to this:

And also i get approve sertificate to use multicast from apple team, and apply it in project

If you’re using the built-in mDNS implementation, you don’t need the multicast entitlement for your mDNS work.

Given that the same code works fine on iOS 16.6, but encounters issues on iOS 17, it seems there might be some changes or additional requirements in iOS 17

Of course, the other possibility is that the code has a bug and some benign change in iOS 17 is triggering this problem. And, honestly, that seems like the most likely option here. If Bonjour were fundamentally broken on iOS 17, I’d have heard about it.

I see a few paths forward:

  • You could dig into the Zeroconf implementation to see what Apple APIs it’s calling. That’ll let you find the source of this error, and we can then talk about why that API might return that error.

  • You could create a new test project using the process I described in Getting Started with Bonjour. Once you get that working, you have some reassurance that our Bonjour APIs are working correctly on iOS 17, and you can use that to guide your investigation of this error in your main app.

  • You could engage with the support channel for the third-party resource you’re using.

Share and Enjoy

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

Error -72007 is NSNetServicesTimeoutError.

With reference to the code you posted, what is zeroconf? Specifically, it is using the built-in mDNS stack? Or is it implementing mDNS itself?

Share and Enjoy

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

Thank you for your response.

What is zeroconf? Zeroconf is a library that enables service discovery over local networks using the mDNS (Multicast DNS) and DNS-SD (DNS Service Discovery) protocols. In my case, I am using the react-native-zeroconf library, which is a React Native wrapper around the native zeroconf functionality provided by iOS and Android.

https://github.com/balthazar/react-native-zeroconf

Is it using the built-in mDNS stack or implementing mDNS itself? The react-native-zeroconf library utilizes the built-in mDNS stack provided by iOS. It does not implement its own mDNS; instead, it interfaces directly with the native iOS networking APIs for service discovery.

Given that the same code works fine on iOS 16.6, but encounters issues on iOS 17, it seems there might be some changes or additional requirements in iOS 17 that affect how the local network and mDNS services are accessed. Could you provide more insight into any changes in iOS 17 that might require updates or adjustments to the app's network configuration or permissions?

Thank you in advance for your assistance.

Thanks for all the extra info.

The react-native-zeroconf library utilizes the built-in mDNS stack provided by iOS.

OK. That’s great news. Carrying around your own mDNS implementation is a really bad idea.

But it does mean that I have to come back to this:

And also i get approve sertificate to use multicast from apple team, and apply it in project

If you’re using the built-in mDNS implementation, you don’t need the multicast entitlement for your mDNS work.

Given that the same code works fine on iOS 16.6, but encounters issues on iOS 17, it seems there might be some changes or additional requirements in iOS 17

Of course, the other possibility is that the code has a bug and some benign change in iOS 17 is triggering this problem. And, honestly, that seems like the most likely option here. If Bonjour were fundamentally broken on iOS 17, I’d have heard about it.

I see a few paths forward:

  • You could dig into the Zeroconf implementation to see what Apple APIs it’s calling. That’ll let you find the source of this error, and we can then talk about why that API might return that error.

  • You could create a new test project using the process I described in Getting Started with Bonjour. Once you get that working, you have some reassurance that our Bonjour APIs are working correctly on iOS 17, and you can use that to guide your investigation of this error in your main app.

  • You could engage with the support channel for the third-party resource you’re using.

Share and Enjoy

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

That’ll let you find the source of this error, and we can then talk about why that API might return that error.

Hi, i added the NS log to the native code, and find the next things:

  1. Zeroconf is find service:
11:53:34.138293+0300 Turkov Zeroconf found service: <NSNetService 0x3011e9220> local. _http._tcp. Turkov-0-000000-26 -1

The code from this log is next:

- (void) netServiceBrowser:(NSNetServiceBrowser *)browser
            didFindService:(NSNetService *)service
                moreComing:(BOOL)moreComing
{
    NSLog(@"Zeroconf found service: %@", service);
    if (service == nil) {
      return;
    }

    NSDictionary *serviceInfo = [RNNetServiceSerializer serializeServiceToDictionary:service resolved:NO];
    [self.bridge.eventDispatcher sendDeviceEventWithName:@"RNZeroconfFound" body:serviceInfo];

    // resolving services must be strongly referenced or they will be garbage collected
    // and will never resolve or timeout.
    // source: http://stackoverflow.com/a/16130535/2715
    self.resolvingServices[service.name] = service;

    service.delegate = self;
    [service resolveWithTimeout:5.0];
}
  1. But then service cannot get the info from service, and rejected by timeout.(By the way i tried to increase the timeout to 10 seconds its not helped.
11:53:39.145311+0300 Turkov Zeroconf Failed to resolve service: <NSNetService 0x3011e9220> local. _http._tcp. Turkov-0-000000-26 -1 with error: {
    NSNetServicesErrorCode = "-72007";
    NSNetServicesErrorDomain = 10;
}

In next step, i see the Error from Serializing service:

2:26:10.649283+0300 Turkov Serializer: Serializing service: <NSNetService 0x3013c60e0> local. _http._tcp. Turkov-0-000000-26 -1

So this part of code is here:

#import "RNNetServiceSerializer.h"
#include <arpa/inet.h>

const NSString *kRNServiceKeysName = @"name";
const NSString *kRNServiceKeysFullName = @"fullName";
const NSString *kRNServiceKeysAddresses = @"addresses";
const NSString *kRNServiceKeysHost = @"host";
const NSString *kRNServiceKeysPort = @"port";
const NSString *kRNServiceTxtRecords = @"txt";

@implementation RNNetServiceSerializer

+ (NSDictionary *) serializeServiceToDictionary:(NSNetService *)service
                                       resolved:(BOOL)resolved
{
    NSMutableDictionary *serviceInfo = [[NSMutableDictionary alloc] init];
    NSLog(@"Serializer: Serializing service: %@", service);

    // Serializing the name of the service
    serviceInfo[kRNServiceKeysName] = service.name;
    NSLog(@"Serializer: Service name: %@", service.name);

    if (resolved) {
        // Serializing additional information when service is resolved
        serviceInfo[kRNServiceKeysFullName] = [NSString stringWithFormat:@"%@%@", service.hostName, service.type];
        NSLog(@"Serializer: Service full name: %@", serviceInfo[kRNServiceKeysFullName]);

        serviceInfo[kRNServiceKeysAddresses] = [self addressesFromService:service];
        NSLog(@"Serializer: Service addresses: %@", serviceInfo[kRNServiceKeysAddresses]);

        serviceInfo[kRNServiceKeysHost] = service.hostName;
        NSLog(@"Serializer: Service host: %@", serviceInfo[kRNServiceKeysHost]);

        serviceInfo[kRNServiceKeysPort] = @(service.port);
        NSLog(@"Serializer: Service port: %d", service.port);
        
        NSDictionary<NSString *, NSData *> *txtRecordDict = [NSNetService dictionaryFromTXTRecordData:service.TXTRecordData];
        NSLog(@"Serializer: TXT records: %@", txtRecordDict);
        
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
        for (NSString *key in txtRecordDict) {
            @try {
                dict[key] = [[NSString alloc]
                            initWithData:txtRecordDict[key]
                            encoding:NSASCIIStringEncoding];
                NSLog(@"Serializer: TXT record key: %@, value: %@", key, dict[key]);
            }
            @catch(NSException *exception) {
                NSLog(@"Serializer: Exception while processing TXT record for key %@: %@", key, exception);
            }
        }
        serviceInfo[kRNServiceTxtRecords] = dict;
    } else {
        NSLog(@"Serializer: Service not resolved yet, skipping additional information");
    }
    return [NSDictionary dictionaryWithDictionary:serviceInfo];
}

So we can see that method is not resolved:

NSLog(@"Serializer: Service not resolved yet, skipping additional information");

Can you help with this info? Thanks!

Additional info: Also - i cannot get the info from service from the therminal on macOS: i can find the service:

dns-sd -B _http._tcp local

Browsing for _http._tcp.local
DATE: ---Tue 17 Sep 2024---
12:59:09.160  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
12:59:09.161  Add        2  12 local.               _http._tcp.          Turkov-0-000000-26

And i cannot get the info from this sevice:

dns-sd -L "Turkov-0-000000-26" _http._tcp local Lookup Turkov-0-000000-26._http._tcp.local DATE: ---Tue 17 Sep 2024--- 12:59:54.020 ...STARTING...

Does it can be problem that service working only on IPv4?
IOS 17, cannot scan LocalNetworkNSNetServicesErrorCode = "-72007"
 
 
Q