Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) Null Key Exception - iOS, Bug #244

Open
twofingerrightclick opened this issue Aug 15, 2022 · 3 comments

Comments

@twofingerrightclick
Copy link

twofingerrightclick commented Aug 15, 2022

Using latest stable Zeroconf 3.6.11
I am trying to get an iOS Xamarin project working for iOS 14.5+ (previously worked on iOS versions prior). It only needs to search for a single service and so I have followed the instructions for adding NSBonjourServices in the Info.plist:

<key>NSLocalNetworkUsageDescription</key>
	<string>Looking for printers with mDNS/Bonjour services</string>
<key>NSBonjourServices</key>
	<array>
		<string>_printer._tcp</string>
	</array>

When calling ZeroconfResolver.ResolveAsync("_printer._tcp.local.") the following exception bubbles up from Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service):

{System.ArgumentNullException: Value cannot be null.Parameter name: key at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00008] in <35fb05e83cf64d249b5a7be1a6f7838a>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].set_Item (TKey key, TValue value) [0x00000] in <35fb05e83cf64d249b5a7be1a6f7838a>:0 at Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) [0x00000] in //Zeroconf/ZeroconfRecord.cs:193 at Zeroconf.BonjourBrowser.RefreshZeroconfHostDict () [0x00121] in //Zeroconf/BonjourBrowser.cs:436 at Zeroconf.BonjourBrowser.ReturnZeroconfHostResults () [0x00028] in //Zeroconf/BonjourBrowser.cs:361 at Zeroconf.ZeroconfNetServiceBrowser.ResolveAsync (Zeroconf.ResolveOptions options, System.Action1[T] callback, System.Threading.CancellationToken cancellationToken, System.Net.NetworkInformation.NetworkInterface[] netInterfacesToSendRequestOn) [0x0010b] in /_/Zeroconf/ZeroconfNetServiceBrowser.cs:39 at Zeroconf.ZeroconfResolver.ResolveAsync (Zeroconf.ResolveOptions options, System.Action1[T] callback, System.Threading.CancellationToken cancellationToken, System.Net.NetworkInformation.NetworkInterface[] netInterfacesToSendRequestOn) [0x000e0] in //Zeroconf/ZeroconfResolver.Async.cs:105 at Zeroconf.ZeroconfResolver.ResolveAsync (System.Collections.Generic.IEnumerable1[T] protocols, System.TimeSpan scanTime, System.Int32 retries, System.Int32 retryDelayMilliseconds, System.Action1[T] callback, System.Threading.CancellationToken cancellationToken...

ZeroconfResolver.IsiOSWorkaroundEnabled resolves to true.

I am trying to run the demo iOS project included in the repo to confirm similar behavior, but I currently can get it working... it builds and deploys, but is just a black screen.

@twofingerrightclick
Copy link
Author

So the exception comes from here:

services[service.ServiceName] = service ?? throw new ArgumentNullException(nameof(service));

The ServiceName on the Service object is not being set (is null) as part of the iOS pipeline of the ResolveAsync. I will see if I can figure out where the ServiceName is supposed to be set, but isn't - Nullable enabled would be helpful here.

@twofingerrightclick
Copy link
Author

I am thinking it should have been set about here in the BonjourBrowser.cs

Service svc = new Service();
svc.Name = GetNsNetServiceName(nsNetService);
svc.Port = (int)nsNetService.Port;
// svc.Ttl = is not available

@twofingerrightclick twofingerrightclick changed the title Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) Exception null Key Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) Null Key Exception Bug Aug 17, 2022
@twofingerrightclick
Copy link
Author

@clairernovotny Please review #246

@twofingerrightclick twofingerrightclick changed the title Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) Null Key Exception Bug Zeroconf.ZeroconfHost.AddService (Zeroconf.IService service) Null Key Exception - iOS, Bug Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant