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

GetHostNameAsync doesn't work on iOS #143

Closed
Immons opened this issue Jan 20, 2022 · 1 comment
Closed

GetHostNameAsync doesn't work on iOS #143

Immons opened this issue Jan 20, 2022 · 1 comment

Comments

@Immons
Copy link

Immons commented Jan 20, 2022

Trying to use this library, as standard .NET DNS implementation doesn't return nice host name.
On iOS Simulator, below code returns fine:

var client = new LookupClient();
return await client.GetHostNameAsync(ip);

on device it throws error:

2022-01-20 14:45:45.395.iOS[1299:342331] System.ArgumentOutOfRangeException: List of configured name servers must not be empty.
Parameter name: servers
  at DnsClient.LookupClient.QueryInternalAsync (DnsClient.DnsQuestion question, DnsClient.DnsQuerySettings queryOptions, System.Collections.Generic.IReadOnlyCollection`1[T] servers, System.Threading.CancellationToken cancellationToken) [0x00061] in <afd7bd4618b64f01ae1ddbabc84fd0e8>:0 
  at DnsClient.DnsQueryExtensions.GetHostNameAsync (DnsClient.IDnsQuery query, System.Net.IPAddress address) [0x0009f] in <afd7bd4618b64f01ae1ddbabc84fd0e8>:0 
  at <project>.DevicesDiscovery.Scanners.DnsHostNameResolver.GetHostNameWithDnsClientNet (System.Net.IPAddress ip) [0x0003a] in /Users/immons/Projects/<project>.DevicesDiscovery/Scanners/DnsScanner.cs:62
@MichaCo
Copy link
Owner

MichaCo commented Jan 21, 2022

The error might be slightly misleading. But this just means that the DNS server auto discovery didn't work.
Which is expected on iOS.

To get the DNS server(s) on mobile, you need to call some different APIs, and until .NET Core supports some way to get that information for you, you have to do that step yourself and initialize the client with the server(s) you found.

That being said, I'm not a mobile developer and especially not on iOS, so if there is some way to get DNS server information I'm happy to look at a PR

@MichaCo MichaCo closed this as completed Jan 21, 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

2 participants