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.
Post
Replies
Boosts
Views
Activity
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:
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];
}
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?