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

unable to get corrent service host name in Android #37

Closed
jet6666 opened this issue Feb 28, 2023 · 4 comments
Closed

unable to get corrent service host name in Android #37

jet6666 opened this issue Feb 28, 2023 · 4 comments
Assignees
Labels
waiting for user feedback Additional information requested from user

Comments

@jet6666
Copy link

jet6666 commented Feb 28, 2023

Description

enableLogging(LogTopic.calls);
currentDiscovery = await startDiscovery('_apple-mobdev2._tcp', ipLookupType: IpLookupType.v4 );
currentDiscovery?.addServiceListener((service, status) async {
developer.log('service.name =${service.name} ,host = ${service.host} .toString= ${service.toString()} ');

in iOS is correct .
in Android , the host is always the ipaddress.

[MethodChannelNsdPlatform] [2023-02-28 17:09:03.488546] [calls] Callback: onServiceDiscovered {handle: 6c6cde2c-6c59-43dd-92e4-fef82dbbf913, service.name: 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d, service.type: _apple-mobdev2._tcp, service.host: null, service.port: null, service.txt: {}}
[MethodChannelNsdPlatform] [2023-02-28 17:09:03.493502] [calls] Call: resolve {handle: f9db7d96-9ef5-44b4-9178-9c4346acaf57, service.name: 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d, service.type: _apple-mobdev2._tcp, service.host: null, service.port: null, service.txt: {}}
[MethodChannelNsdPlatform] [2023-02-28 17:09:03.563141] [calls] Callback: onResolveSuccessful {handle: f9db7d96-9ef5-44b4-9178-9c4346acaf57, service.name: 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d, service.type: _apple-mobdev2._tcp, service.host: 192.168.13.24, service.port: 32498, service.txt: {}}
[log] service.name =7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d ,host = 192.168.13.24 .toString= Service (name: 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d, service type: _apple-mobdev2._tcp, hostname: 192.168.13.24, port: 32498, txt: {}, addresses: [InternetAddress('192.168.13.24', IPv4)])

in Linux :

avahi-browse -rv _apple-mobdev2._tcp
Server version: avahi 0.6.31; Host name: linux.local
E Ifce Prot Name Type Domain

  • enp0s31f6 IPv4 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d _apple-mobdev2._tcp local
    = enp0s31f6 IPv4 7c:01:91:1e:3a:9d@fe80::7e01:91ff:fe1e:3a9d _apple-mobdev2._tcp local
    hostname = [jiujiu.local]
    address = [192.168.13.24]
    port = [32498]
    txt = []
    : All for now
    : Cache exhausted`

I use App Service Browser , It can get corrent hostname.

Scenario

Other (please describe above)

Platform

Android

@sebastianhaberey
Copy link
Owner

I was able to reproduce this on Android 13 API 33 with the example application:

[MethodChannelNsdPlatform] [2023-03-02 16:39:09.543158] [calls] Callback: onResolveSuccessful {handle: e8f6662a-d900-4d2c-9db3-ecdfd1826d09, service.name: Some Service, service.type: _http._tcp, service.host: 10.0.2.15, service.port: 56360, service.txt: {a-null: null, a-blank: null, a-string: [206, 186, 207, 140, 207, 131, 206, 188, 206, 181]}}

Looking into it now.

@sebastianhaberey
Copy link
Owner

@jet6666 in your setup above what kind of Android device did you use (phone, Android version)? And am I correct that your Android device is called "jiujiu"?

@sebastianhaberey sebastianhaberey added the waiting for user feedback Additional information requested from user label Mar 5, 2023
@sebastianhaberey
Copy link
Owner

Here's what I found:

  • The plugin uses InetAddress#getCanonicalHostName to resolve the IP adresses coming from the NsdManager
  • The method returns the adress as a string if cannot resolve the host name (this is what you're seeing)

When I tried this out on the emulator (see post above) the host name could not be resolved. I don't exactly know why that is, but my guess is it's because the emulator device is not really part of the DNS network, so it doesn't get a proper hostname assigned.

On a real device it should work though - and it did on my device (Android 12). To be able to find out more about this I'd need some information about your specific setup.

@sebastianhaberey sebastianhaberey self-assigned this Mar 10, 2023
@sebastianhaberey
Copy link
Owner

I can not reproduce this behavior on physical devices, only on the emulator, where the missing host name is expected. Please feel free to open another issue if you observe this on a real-life device.

@sebastianhaberey sebastianhaberey closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for user feedback Additional information requested from user
Projects
None yet
Development

No branches or pull requests

2 participants