Open addibouk opened 1 year ago
I am running into the same issue. After looking into it further, it looks like when the ZeroconfHost is created in BonjourBrowser.cs (which only runs on iOS), the ServiceName is not set like it is in the equivalent non-iOS code. I am looking at the RefreshZeroconfHostDict() method, which currently starts on line 375. Starting on line 399, I see the following:
Service svc = new Service();
svc.Name = GetNsNetServiceName(nsNetService);
svc.Port = (int)nsNetService.Port;
// svc.Ttl = is not available
// DS: We need to set svc.ServiceName or we get a NullReferenceException
// Name is the name retrieved from the PTR record, e.g. _http._tcp.local.
// ServiceName is the name retrieved from the SRV record e.g. myserver._http._tcp.local.
// I'm not sure if this fix works across the board, e.g. when two devices of the same model exist on the same network
svc.ServiceName = $"{nsNetService.Name}{nsNetService.Type}{nsNetService.Domain}";
The fix that I added causes the code to succeed in my home, but I am not sure if it is a "full fix" - when more than one device in the network tries to use the same ServiceName, the service provider is supposed to append a number to the end in a headless application, or prompt the user for a new name in a UI-based application, to avoid naming conflicts. This is reflected in the SRV record. I'm not familiar enough with this code to know if my fix addresses this situation, nor do I currently have a way of testing. Hopefully this will help someone, though.
When using Zeroconf on iOS I am receiving the following exception when it discovers my network service...
Any ideas?