flutter_nsd icon indicating copy to clipboard operation
flutter_nsd copied to clipboard

Services are not discovered on Android

Open mbalmer opened this issue 1 year ago • 2 comments

Using this in a flutter app for iOS and Android. While it works as expected on iOS, it does not discover the services on Android. This is on Android 14 (Samsung Galaxy A34 5G)

mbalmer avatar May 25 '24 09:05 mbalmer

Here is some logcat output, the code runs for 30 seconds, apparently something is found by MdnsDiscoveryManager, but not returned to the stream:

2024-05-25 12:04:23.842 25445-25493 flutter                 ch.msys.trx_control                  I  trx-control: start discovery
2024-05-25 12:04:23.845  1501-1798  serviceDiscovery        system_server                        I  [MdnsDiscoveryManager] Registering listener for serviceType: _trx-control._tcp.local
2024-05-25 12:04:24.948  1501-1798  serviceDiscovery        system_server                        I  [MdnsDiscoveryManager._trx-control._tcp.local-104/40] Handling response from service: trx-control (trxd) on trx-control-w2, newServiceFound: false, serviceBecomesComplete: false, responseIsComplete: true
2024-05-25 12:04:53.856 25445-25493 flutter                 ch.msys.trx_control                  I  trx-control: stop discovery
2024-05-25 12:04:53.860  1501-1798  serviceDiscovery        system_server                        I  [MdnsDiscoveryManager] Unregistering listener for serviceType:_trx-control._tcp.local

mbalmer avatar May 25 '24 10:05 mbalmer

I turns out that the service name matters. If I try to discover "_trx-control._tcp" it is found on iOS, but not on Android. If I add a dot ("_trx-control._tcp.") then it is discovered on iOS and Android. This is weird, and maybe worth mentioning in the docs?

mbalmer avatar May 25 '24 10:05 mbalmer