Giter Club home page Giter Club logo

nsd's Introduction

nsd's People

Contributors

marcodkunz avatar porum avatar sebastianhaberey avatar tekawa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nsd's Issues

Is there a way to scan all mDNS in the network

I am interested to scan for all NSD / DNS-SD / Bonjour / mDNS devices in the network.

I saw that the default serviceType is _http._tcp but it does not find all the mDNS devices at home I guess because they have different service types.

Is there a way to scan all the types at once?.

Initial discovery does not properly detect already registered services.

Description

Tested with Android 13 / Windows 10 and the sample app (https://github.com/sebastianhaberey/nsd/tree/main/nsd/example).

Steps to reproduce:

  1. Starting the sample app on Windows (as Desktop-App).
  2. Register a service with the Windows-Sample-App.
  3. Starting another instance of the sample app on an Android 13 device.
  4. Start a discovery with the Android-Sample-App.

Expected: Discovers and shows the Service

Result: No Service is discovered.

  1. Register another service with the windows app.
  2. The service is shown in the Android app directly.
  3. Using Hot-Restart on the Android App (and starting a new discovery), still only the second service is shown.
  4. Killing the android app instance and restarting it ( and starting a new discovery) no service is shown.

Using "dns-sd -B " now shows both registered services instantly.

Am I doing something wrong? First I thought it is related to my code. But the same issue remains with the sample app as described above. The only thing I changed was the serviceTypeDiscover/serviceTypeRegister to "_xxx._tcp".

Is there something I can do to also discover services that were registered before the app was started?

Thanks

Scenario

Run the example application

Platform

Android

Add alternative discovery listening mechanism to handle "service found" and "service lost" events manually

Description

The existing discovery mechanism where the services reside in a plugin-managed observable collection is geared towards displaying services in a UI and having the user select one. In other use cases the client might want to maintain the collection manually (for example if the results must be filtered) or just react to the found / lost events without maintaining a collection at all. This should be trivial to add and will give the user more choice.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

All of them

Check Windows Version on startup

Description

Is it possible to check Windows version on startup, and don't call unsupported APIs on lower versions of Windows? My app crashes on older versions of Windows because there's no DnsServiceConstructInstance in DNSAPI.dll, if you could add a version check before calling that it would be fine just discovery service won't work, instead of crashing.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Windows

TTL support in Service class

Description

I can't change the TTL parameter at register method when I register a Service.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

No response

stopDiscovery Not working giving below exception

Description

ERROR:

NsdError (message: "stopDiscovery: MulticastLock under-locked nsdMulticastLock", cause: internalError)

NsdError (message: "stopDiscovery: MulticastLock under-locked nsdMulticastLock", cause: internalError)
I/flutter ( 2026): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 2026): │ #0 MethodChannelNsdPlatform.invoke. (package:nsd_platform_interface/src/method_channel_nsd_platform.dart:201:28)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#1 _rootRunUnary (dart:async/zone.dart:1434:47)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#2 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#3 _FutureListener.handleError (dart:async/future_impl.dart:177:22)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#4 Future._propagateToListeners.handleError (dart:async/future_impl.dart:778:47)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#5 Future._propagateToListeners (dart:async/future_impl.dart:799:13)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#6 Future._completeError (dart:async/future_impl.dart:609:5)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#7 _completeOnAsyncError (dart:async-patch/async_patch.dart:272:13)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#8 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart)
I/flutter ( 2026): │ Nimrodda/flutter_nsd#9
I/flutter ( 2026): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 2026): │ 12:05:02.933 (+0:00:46.781794)
I/flutter ( 2026): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter ( 2026): │ ⛔ ERROR OCCURS NsdError (message: "stopDiscovery: MulticastLock under-locked nsdMulticastLock", cause: internalError)

I've created a custom demo project for to review and reproduce this error:

Clone link - https://github.com/harishkthedeveloper/mdns_demo.git

I've also provided a demo video and log file for your convenience:

Demo video & log file - https://drive.google.com/drive/folders/1cQdpHMdnf3s-ofJ8kjixmOHL55P3AbO8?usp=sharing

To reproduce the issue, please follow these steps:

NOTE: In the file nsd_service.dart, replace String serviceTypeDiscover = "<add_your_service>._tcp"; with your service name.

Click on the "Scan" button to go to the scanned device list page.
Then, click the back button on the Appbar (we are stopping the service in the Dispose method).
Try to switch between Wi-Fi networks in your mobile settings and return to the app.
Repeat the above three steps more than 10 times to encounter the following errors:
Errors:

[MDNS] ERROR: ID:- 4961d42f-eed2-4952-89c9-9e9fad13c746 NsdError (message: "stopDiscovery: MulticastLock under-locked nsdMulticastLock", cause: internalError)

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: NsdError (message: "Maximum outstanding requests reached", cause: maxLimit)
I'm seeking your guidance on why the service is not getting stopped or closed, and how we can avoid these errors. If these errors persist, it becomes challenging to provide users with a new device list. Your insights and suggestions will be highly appreciated.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

unable to get corrent service host name in Android

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

Maximum outstanding requests reached

I got this error "Unhandled Exception: NsdError (message: "Maximum outstanding requests reached", cause: maxLimit)"

  • After getting some discovery I got this
  • After uninstalling the app I got a new discovery but still, this exception arrive.

How I can solve this error?

service name's bug ?

Description

`[log] new type = _nvstream_dbd._tcp
E/flutter (23866): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NsdError (message: "Service type must be in format .: _nvstream_dbd._tcp", cause: illegalArgument)

E/flutter (23866): #0 MethodChannelNsdPlatform.assertValidServiceType (package:nsd_platform_interface/src/method_channel_nsd_platform.dart:226:7)

E/flutter (23866): #1 MethodChannelNsdPlatform.startDiscovery (package:nsd_platform_interface/src/method_channel_nsd_platform.dart:38:5)

E/flutter (23866): #2 startDiscovery (package:nsd/nsd.dart:31:35)`

the plugin code goes
return RegExp(r'^_[a-zA-Z0-9-]{1,15}._(tcp|udp)').hasMatch(type);

Scenario

Use the plugin in my own application via Flutter dependency

Platform

All of them

Find services registered after discovery is started

Hi
In my Flutter app I have case when new services are registered and they are not discovered by mdns discovery. This happens in about 10-20% of tests. If I stop and start discovery - they appear.

So only approach is to implement restart of discovery browsers OR this is a bug.

Incompatible classes error on Android

Hi team,
I have an issue on Android.
I got the error:

e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors
e: .../.gradle/caches/transforms-2/files-2.1/185d46b6321985f52dcc07c04b9e0199/jetified-kotlin-stdlib-common-1.5.31.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
...
...
e: .../.pub-cache/hosted/pub.dartlang.org/nsd_android-1.0.3/android/src/main/kotlin/com/haberey/flutter/nsd_android/NsdAndroidPlugin.kt: (15, 27): Unresolved reference: HashMap
...

What's wrong there? Have any ideal to help fix this issue? Thank you so much.

Integration tests failing on Github CI

Description

The Windows, macOS and Android integration tests have been failing on the CI recently.

Currently the macos test does not start, while windows tests fail randomly (see issue #39), as do the Android tests.

The tests pass 100% of the time when executing locally (on all platforms). Also, they used to pass 100% on the CI a couple of months ago, and the codebase hasn't changed since then. It seems reasonable to assume the error lies in the CI setup rather than the plugin itself.

Unfortunately I currently don't have the time to investigate this further. I will remove the corresponding badges from the documentation for now, and hope I'll have some time to look at this in the future.

Scenario

Other (please describe above)

Platform

All of them

Kotlin Compiler Error

Hi, i am using your package and run into this error below when building the application.

======================================================

Conflicting overloads: internal fun deserializeHandle(arguments: Map<String, Any?>?): String? defined in com.haberey.flutter.nsd_android in file Serialization.kt, internal fun deserializeHandle(arguments: Map<String, Any?>?): String? defined in com.haberey.flutter.nsd_android in file Serialization.kt

  • What went wrong:
    Execution failed for task ':nsd_android:compileDebugKotlin'.
    Compilation error. See log for more details

======================================================

I'm currently using flutter version 2.10.4. Below is my flutter doctor

[√] Flutter (Channel unknown, 2.10.4, on Microsoft Windows [Version 10.0.22000.556], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc2)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.3)
[√] VS Code (version 1.66.0)
[√] Connected device (4 available)
[√] HTTP Host Availability

Could you check it for me, thanks a lot

Auto resolve to new IP address

Description

After the service registration, i changed my ip address in setting and back to app, the discovery result still show the old ip address, i tried to unregister and register the service and it still resolve to old IP address.

I closed the app and reopen, it still resolve to old IP address.

i killed the app and reopen, then it resolve to new IP address.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

Several strange behaviors, maybe Android

Description

I'm writing a library gluing automagic communications over NSD, and experiencing some strange behavior. I'm currently testing, on:

  • (thing, service type, name)
  • A windows laptop, _WORK._tcp, 1d31fa57-150d-4f50-b4e7-6393695e3d40
  • A windows desktop, _DESK._tcp, bbae63ae-9a38-4cfb-81e2-50c34e9f444b
  • An Android phone, _NOTE._tcp, 7cf86e76-fa59-4647-ad2a-957af064c3c0
  • An Android phone, _PIXEL._tcp, 2dbf73d1-74c4-4c1c-86fc-6bf7d2696288

They all have wifi, but DESK also has several other interfaces.

Note that apparently on Android, registering a Service gives registration.service.host == null, so...well, I suddenly realize some of my code is pointless, but I don't think that particular thing is the problem. (Side note: is there an easy way to get the host before registering, so I can add the ip addresses to addresses before registering a host potentially with no way to contact it?)

But anyway. Test results. (Note that I filtered out self-scans, and only tried to connect to things that showed up in a scan.)

Scanning:
Everything shows up in everything else's scans, except that PIXEL shows up for NOTE but not for DESK or WORK.

Trying to connect to scanned things:
Nothing can connect to WORK (but I think that's a firewall thing, so that's ok).
Everything can connect to DESK.
Initially WORK failed to connect to NOTE, and I don't know why, but on a second attempt it succeeded.
So, WORK and PIXEL but not DESK can connect to NOTE.
NOTE can connect to PIXEL (but was the only thing that could scan it, anyway).

Here's some more info, from console commands on DESK.

C:\Users\Erhannis>dns-sd -B _WORK._tcp
Browsing for _WORK._tcp
Timestamp     A/R Flags if Domain                    Service Type              Instance Name
19:00:38.130  Add     2 15 local.                    _WORK._tcp.               1d31fa57-150d-4f50-b4e7-6393695e3d40
^C
C:\Users\Erhannis>dns-sd -B _DESK._tcp
Browsing for _DESK._tcp
Timestamp     A/R Flags if Domain                    Service Type              Instance Name
19:00:47.243  Add     3  4 local.                    _DESK._tcp.               bbae63ae-9a38-4cfb-81e2-50c34e9f444b
19:00:47.244  Add     3  5 local.                    _DESK._tcp.               bbae63ae-9a38-4cfb-81e2-50c34e9f444b
19:00:47.244  Add     2 15 local.                    _DESK._tcp.               bbae63ae-9a38-4cfb-81e2-50c34e9f444b
^C
C:\Users\Erhannis>dns-sd -B _NOTE._tcp
Browsing for _NOTE._tcp
Timestamp     A/R Flags if Domain                    Service Type              Instance Name
19:01:07.796  Add     2 15 local.                    _NOTE._tcp.               7cf86e76-fa59-4647-ad2a-957af064c3c0
^C
C:\Users\Erhannis>dns-sd -B _PIXEL._tcp
Browsing for _PIXEL._tcp
Timestamp     A/R Flags if Domain                    Service Type              Instance Name
19:01:21.062  Add     2 15 local.                    _PIXEL._tcp.              2dbf73d1-74c4-4c1c-86fc-6bf7d2696288
^C
C:\Users\Erhannis>dns-sd -L 1d31fa57-150d-4f50-b4e7-6393695e3d40 _WORK._tcp
Lookup 1d31fa57-150d-4f50-b4e7-6393695e3d40._WORK._tcp.local
19:01:48.586  1d31fa57-150d-4f50-b4e7-6393695e3d40._WORK._tcp.local. can be reached at mewer-intune.local.:63418 (interface 15)
^C
C:\Users\Erhannis>dns-sd -L bbae63ae-9a38-4cfb-81e2-50c34e9f444b _DESK._tcp
Lookup bbae63ae-9a38-4cfb-81e2-50c34e9f444b._DESK._tcp.local
19:02:12.467  bbae63ae-9a38-4cfb-81e2-50c34e9f444b._DESK._tcp.local. can be reached at DESKTOP-F6GR5LG.local.:23209 (interface 4) Flags: 1
19:02:12.467  bbae63ae-9a38-4cfb-81e2-50c34e9f444b._DESK._tcp.local. can be reached at DESKTOP-F6GR5LG.local.:23209 (interface 5) Flags: 1
19:02:12.468  bbae63ae-9a38-4cfb-81e2-50c34e9f444b._DESK._tcp.local. can be reached at DESKTOP-F6GR5LG.local.:23209 (interface 15)
^C
C:\Users\Erhannis>dns-sd -L 7cf86e76-fa59-4647-ad2a-957af064c3c0 _NOTE._tcp
Lookup 7cf86e76-fa59-4647-ad2a-957af064c3c0._NOTE._tcp.local
19:02:33.093  7cf86e76-fa59-4647-ad2a-957af064c3c0._NOTE._tcp.local. can be reached at Android.local.:37047 (interface 15)
^C
C:\Users\Erhannis>dns-sd -L 2dbf73d1-74c4-4c1c-86fc-6bf7d2696288 _PIXEL._tcp
Lookup 2dbf73d1-74c4-4c1c-86fc-6bf7d2696288._PIXEL._tcp.local
19:03:03.779  2dbf73d1-74c4-4c1c-86fc-6bf7d2696288._PIXEL._tcp.local. can be reached at Android-3.local.:41299 (interface 15)
^C
C:\Users\Erhannis>ping mewer-intune.local

Pinging mewer-intune [fe80::3177:7fce:7436:b7f5%15] with 32 bytes of data:
Reply from fe80::3177:7fce:7436:b7f5%15: time=2ms
Reply from fe80::3177:7fce:7436:b7f5%15: time=4ms
Reply from fe80::3177:7fce:7436:b7f5%15: time=9ms
Reply from fe80::3177:7fce:7436:b7f5%15: time=4ms

Ping statistics for fe80::3177:7fce:7436:b7f5%15:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 2ms, Maximum = 9ms, Average = 4ms

C:\Users\Erhannis>ping DESKTOP-F6GR5LG.local

Pinging DESKTOP-F6GR5LG [fe80::2012:a99a:2011:43ff%4] with 32 bytes of data:
Reply from fe80::2012:a99a:2011:43ff%4: time<1ms
Reply from fe80::2012:a99a:2011:43ff%4: time<1ms
Reply from fe80::2012:a99a:2011:43ff%4: time<1ms
Reply from fe80::2012:a99a:2011:43ff%4: time<1ms

Ping statistics for fe80::2012:a99a:2011:43ff%4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\Users\Erhannis>ping Android.local

Pinging Android.local [192.168.1.43] with 32 bytes of data:
Reply from 192.168.1.43: bytes=32 time=81ms TTL=64
Reply from 192.168.1.43: bytes=32 time=93ms TTL=64
Reply from 192.168.1.43: bytes=32 time=108ms TTL=64
Reply from 192.168.1.43: bytes=32 time=16ms TTL=64

Ping statistics for 192.168.1.43:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 16ms, Maximum = 108ms, Average = 74ms

C:\Users\Erhannis>ping Android-3.local
Ping request could not find host Android-3.local. Please check the name and try again.

C:\Users\Erhannis>

Note that dns-sd was able to see PIXEL's service, but the reported host was unresolvable. Contrasted with NSD, which did not show it in the scan.

I also note that PIXEL, to the Android phones, is Pixel-4a.lan, and NOTE is android-[buncha characters].lan, and from DESK, pinging Pixel-4a.lan succeeds.

Any idea why PIXEL is only showing up in scans for the other Android? The difference in naming, perhaps? Does NSD resolve the host before confirming the scan? Any idea how to get it to work consistently? (And any idea why the connection might have initially failed from DESK to NOTE?)

Scenario

Use the plugin in my own application via Flutter dependency

Platform

All of them

mDNS not working on Android 12

Description

Hi,
I'm using your library to discover 2 types of mDNS services.
It works fine on Android 9, but on Android 12 it is not discovering services or only one/two from 10 possible.
If I keep app live for long time - at some point after several minutes services appear.

I guess that services that I'm searching for can have some issues. Can I somehow collect info for problem(s)?

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

Expose performIpLookup interface

Description

Hi, I would like to convert xxxxxx.local address to IP address, but it seems that performIpLookup is not exposed. Could you please make it public so I can call it?

Scenario

Use the plugin in my own application via Flutter dependency

Platform

All of them

NsdError (message: "missing required configuration

Description

Hello bro

thanks for this plugin it works great on android and on an ios emulator
but not working on real ios device iPad or iPhone
it shows an error
Unhandled Exception: NsdError (message: "missing required configuration", cause: internalError)

I have also added
NSLocalNetworkUsageDescription
Required to discover local network devices
NSBonjourServices

_http._tcp
to my info file but nothing works..

please help

Thanks

Scenario

Use the plugin in my own application via Flutter dependency

Platform

None

Service name validation

Description

Hello!

In my company we use _company_project._tcp , I decided to remove the native implementation of NSD in our Android/IOS projects and replace it with your library. I was surprised when I found that I can't use it because it can't validate our service name with this regular expression "r'^[a-zA-Z0-9-]{1,15}.( tcp |udp)'". I haven't seen any application blocking discovery of this service. Could you fix this please?

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

removeServiceListener((service, status) => {}) not working

Description

Hi, I was trying to remove a listener using the provided method .
Steps I followed.
Discovered Service (startDiscovery with autoResolve false) -> on discovered ResolvedService(resolve(service)) --> onServiceLost() remove listener listener is not removed.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

flutter unhandled exception "Binding has not yet been initialized."

Description

import 'dart:isolate';

import 'package:flutter/material.dart';
import 'package:multicast_dns/multicast_dns.dart';
import 'package:nsd/nsd.dart';

Future<void> echo(SendPort sender) async {
  var name = '_ipp._tcp';

  final discovery = await startDiscovery(name);
  discovery.addServiceListener((service, status) {
    debugPrint('found service ${service.name}');
  });
// ...

  //await stopDiscovery(discovery);

  debugPrint("echo() the Isolate has been spawned!");
  ReceivePort receivePort = ReceivePort();
  sender.send(receivePort.sendPort);
  receivePort.listen((data) {
    String msg = data[0];
    SendPort replyTo = data[1];
    debugPrint("Isolate received: $msg");

    replyTo.send("Greetings from echo() the Isolate!");
  });
}

Future sendReceive(SendPort port, String msg) {
  ReceivePort receivePort = ReceivePort();
  port.send([msg, receivePort.sendPort]);
  return receivePort.first;
}

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  ReceivePort receivePort = ReceivePort();
  Future<Isolate> remote = Isolate.spawn(echo, receivePort.sendPort);
  remote.then((_) => receivePort.first).then((sendPort) {
    sendReceive(sendPort, "message sent from main()").then((msg) {
      debugPrint("Main received: $msg");
    });
  });
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      theme: ThemeData.dark(),
      home: const Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Material App Bar'),
      ),
      body: const Center(
        child: Text('some text'),
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}
Error

E/flutter (17968): [ERROR:flutter/runtime/dart_isolate.cc(1098)] Unhandled exception:
E/flutter (17968): Binding has not yet been initialized.
E/flutter (17968): The "instance" getter on the ServicesBinding binding mixin is only available once that binding has been initialized.
E/flutter (17968): Typically, this is done by calling "WidgetsFlutterBinding.ensureInitialized()" or "runApp()" (the latter calls the former). Typically this call is done in the "void main()" method. The "ensureInitialized" method is idempotent; calling it multiple times is not harmful. After calling that method, the "instance" getter will return the binding.
E/flutter (17968): In a test, one can call "TestWidgetsFlutterBinding.ensureInitialized()" as the first line in the test's "main()" method to initialize the binding.
E/flutter (17968): If ServicesBinding is a custom binding mixin, there must also be a custom binding class, like WidgetsFlutterBinding, but that mixes in the selected binding, and that is the class that must be constructed before using the "instance" getter.
E/flutter (17968): #0 BindingBase.checkInstance. (package:flutter/src/foundation/binding.dart:287:9)
E/flutter (17968): #1 BindingBase.checkInstance (package:flutter/src/foundation/binding.dart:369:6)
E/flutter (17968): #2 ServicesBinding.instance (package:flutter/src/services/binding.dart:55:54)
E/flutter (17968): #3 MethodChannel.setMethodCallHandler (package:flutter/src/services/platform_channel.dart:538:51)
E/flutter (17968): #4 new MethodChannelNsdPlatform (package:nsd_platform_interface/src/method_channel_nsd_platform.dart:31:20)
E/flutter (17968): #5 NsdPlatformInterface._instance (package:nsd_platform_interface/src/nsd_platform_interface.dart:18:43)
E/flutter (17968): #6 NsdPlatformInterface._instance (package:nsd_platform_interface/src/nsd_platform_interface.dart)
E/flutter (17968): #7 NsdPlatformInterface.instance (package:nsd_platform_interface/src/nsd_platform_interface.dart:20:47)
E/flutter (17968): #8 startDiscovery (package:nsd/nsd.dart:31:26)
E/flutter (17968): #9 echo (package:flutter_demo3/main.dart:10:27)
E/flutter (17968): #10 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:300:17)
E/flutter (17968): #11 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

</details>

### Scenario

Use the plugin in my own application via Flutter dependency

### Platform

None

Flutter windows app crashes randomly on start

Version of plugin: nsd: ^2.3.0
Same code works on iOs and Android without problem.
Here is what Windows event viewer reporst:

Faulting application name: hn_app_flutter.exe, version: 1.0.0.0, time stamp: 0x649e81df
Faulting module name: nsd_windows_plugin.dll, version: 0.0.0.0, time stamp: 0x64914406
Exception code: 0xc000041d
Fault offset: 0x0000000000025069
Faulting process id: 0x41c0
Faulting application start time: 0x01d9ab2322902b48
Faulting application path: C:\Projects\hn-app-flutter\build\windows\runner\Debug\hn_app_flutter.exe
Faulting module path: C:\Projects\hn-app-flutter\build\windows\runner\Debug\nsd_windows_plugin.dll
Report Id: cf6b7327-95b1-4fff-9388-9634dc8d49e5
Faulting package full name:
Faulting package-relative application ID:

Support for IP addresses

This seems to be a common request, so I'm adding this issue for discussion. I'm still unsure if IP addresses should be part of this API, or if they are out of scope. My understanding is that connecting to a resolved service can and should be done using the host name / port combination. Apple representative "Eskimo" writes on their developer forum:

When you’re done with the resolve operation don’t build the URL with IP addresses based on the addresses property. Rather, build a URL with a DNS name based on the hostName property. This is easier and it’ll work better in various edge cases.

So I'd like to hold out implementing this feature until I'm more certain about its use cases. Feel free to comment here.

(warning) 'com.haberey/nsd' channel message on a non-platform thread

Description

Hi, here's just a warning from the Flutter environment. Does not seem to impact functionality yet, but this probably should be addressed.

GIVEN I run a Flutter Windows app on Windows 11 with Flutter 3.13.8
WHEN trying to register a service with register / Future<Registration> register(Service service)
THEN I receive the following warning: [ERROR:flutter/shell/common/shell.cc(1004)] The 'com.haberey/nsd' channel sent a message from native to Flutter on a non-platform thread. Platform channel messages must be sent on the platform thread. Failure to do so may result in data loss or crashes, and must be fixed in the plugin or application code creating that channel.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Windows

`MissingPluginException` only on release mode `NSDError(Message: "MissingPluginImplementation" found for method register on channel com.haberey/nsd", cause: InternalError)`

All tests/runs are done by using real devices

Environment

  • Flutter
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version 10.0.19043.1706], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.13)
[√] Android Studio (version 2020.3)
[√] IntelliJ IDEA Community Edition (version 2021.3)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!
  • Dart
Dart SDK version: 2.16.0 (stable) (Mon Jan 31 15:28:59 2022 +0100) on "windows_x64"

Tested devices:

  • Samsung Galaxy A30
Samsung Exynos 7 Octa 7904 (14 nm)
Octa-core, 1800 MHz, ARM Cortex-A73 and ARM Cortex-A53, 64-bit
Mali-G71 MP2
4GB LPDDR4
64GB, available to use: 49.6 GB
microSDXC up to 512 GB
Android 11, Samsung One UI
  • Xiaomi M4 PRO
MediaTek Dimensity 810 5G MT6833 (6 nm)
Octa-core, 2400 MHz, Cortex-A76, 64-bit
Mali-G57 MC2
4GB LPDDR4
128GB Storage
microSDXC up to 1024 GB
Smartphone
Android (11), MIUI 12.5 UI

Context

This is a "Join Room" page.

That is, this page calls startDiscovery on init and stopDiscovery on dispose.

And it list all available services on the local network.

The plugin works fine when debug and profile mode.

But the plugin throws this exception in release mode

// I'm using `flutter_hooks` to widget manage state/lifecycle (cause I use a lot of `AnimationControllers`)
useEffect(
  () {
    // Equivalent to `initState()`
    Discovery? discovery;

    void updateServices() => services.value = discovery!.services;

    Future<void> discoveryServices() async {
      discovery = await startDiscovery(kServiceType, autoResolve: false);

      discovery?.addListener(updateServices);

      updateServices();

      isLoading.value = false;
    }

    discoveryServices();

    // The return function is equivalent to `dispose()`
    return () async {
      if (discovery != null) await stopDiscovery(discovery!);

      discovery?.removeListener(updateServices);
      discovery?.dispose();
    };
  },
  const [],
);

This print is from the page Create Room which is the opposite of Join Room but the same error/exception is thrown

I already have tried:

  • flutter build apk --no-shrink
  • This one either:
minifyEnabled false
shrinkResources false

nsd 2.3.1 Not compatible uuid 4.1.0

Because no versions of nsd match >2.3.1 <3.0.0 and nsd 2.3.1 depends on nsd_platform_interface ^1.6.0, nsd ^2.3.1 requires nsd_platform_interface ^1.6.0.
Because nsd_platform_interface 1.6.0 depends on uuid ^3.0.7 and no versions of nsd_platform_interface match >1.6.0 <2.0.0, nsd_platform_interface ^1.6.0 requires uuid ^3.0.7.
Thus, nsd ^2.3.1 requires uuid ^3.0.7.

`stopDiscovery` should `dispose()` the `Discovery`

Description

Maybe I'm missing something, but I think stopDiscovery should dispose() the Discovery.

Alternatively, it should be documented, that the developer is considered to be the object's owner and should therefore dispose the Discovery themself.

Scenario

Use the plugin in my own application via Flutter dependency

Platform

None

Max request reached when discover all service-type

Description

when I discovered all services
:
final discovery = await startDiscovery('_services._dns-sd._udp', autoResolve: false);

there are more than 10 service types :

if I use
`
for ( var type in allTypes ) {
final discovery = await startDiscovery( type );
discovery.addListener(() {
// discovery.services contains discovered services
});

// ...

await stopDiscovery(discovery);
}

`

there will be an error :
E/flutter (32009): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NsdError (message: "Maximum outstanding requests reached", cause: maxLimit)

help me how to solve this. thanks

Scenario

Use the plugin in my own application via Flutter dependency

Platform

All of them

Works on iOS sim but not on actual device

It works on the iOS Sim but on the actual device...

  1. Discovery
    No response or error message but nothing is being output

  2. Registration
    Have this error message:
    [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NsdError (message: "missing required configuration", cause: internalError)

CI: Windows tests fail randomly with current runner image

Description

Windows tests fail on current CI on runner windows-2022 image tag win22/20230307.2 which contains Windows Server 202210.0.20348 Build 1547. The tests that fail vary from run to run, but at least one test fails. These tests are run automatically if Windows sources change, or manually. Last successful run was on 06.06.2022 on runner windows-2022 image tag win22/20220529.1 which contains Windows Server 2022 10.0.203348 Build 707.

It doesn't seem possible to revert runner images to previous versions and I don't have a live Windows Server 2022 installation to test this. Tests pass reliably on current Windows 10 (10.0.19045.2673) machine (see below).

Test output on Windows 10 test machine (3 runs)

C:\Dokumente\Projekte\nsd\nsd\example(main -> origin)                                 
λ flutter test -r expanded -d windows integration_test\nsd_test.dart                  
Building Windows application...                                                       
00:00 +0: Registration, discovery and unregistration of multiple services             
00:11 +1: Verify basic attributes of registered service                               
00:12 +2: Verify txt attribute of registered service                                  
00:14 +3: Registration is possible if port is in use                                  
00:15 +4: Find all available service types                                            
00:15 +5: Look up IP addresses for service                                            
00:16 +6: (tearDownAll)                                                               
00:16 +6: All tests passed!                                                           
                                                                                      
C:\Dokumente\Projekte\nsd\nsd\example(main -> origin)                                 
λ flutter test -r expanded -d windows integration_test\nsd_test.dart                  
Building Windows application...                                                       
00:00 +0: Registration, discovery and unregistration of multiple services             
00:11 +1: Verify basic attributes of registered service                               
00:12 +2: Verify txt attribute of registered service                                  
00:14 +3: Registration is possible if port is in use                                  
00:14 +4: Find all available service types                                            
00:15 +5: Look up IP addresses for service                                            
00:16 +6: (tearDownAll)                                                               
00:16 +6: All tests passed!                                                           
                                                                                      
C:\Dokumente\Projekte\nsd\nsd\example(main -> origin)                                 
λ flutter test -r expanded -d windows integration_test\nsd_test.dart                  
Building Windows application...                                                       
00:00 +0: Registration, discovery and unregistration of multiple services             
00:11 +1: Verify basic attributes of registered service                               
00:12 +2: Verify txt attribute of registered service                                  
00:14 +3: Registration is possible if port is in use                                  
00:15 +4: Find all available service types                                            
00:15 +5: Look up IP addresses for service                                            
00:16 +6: (tearDownAll)                                                               
00:16 +6: All tests passed!                                                           

Flutter doctor output on Windows 10 test machine

[√] Flutter (Channel stable, 3.7.7, on Microsoft Windows [Version 10.0.19045.2673], locale de-DE)
    • Flutter version 3.7.7 on channel stable at C:\Tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2ad6cd72c0 (6 days ago), 2023-03-08 09:41:59 -0800
    • Engine revision 1837b5be5f
    • Dart version 2.19.4
    • DevTools version 2.20.1

[X] Windows Version (Unable to confirm if installed Windows version is 10 or greater)

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.1)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32516.85
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.67.1)
    • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2673]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 102.0.5005.63
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 110.0.1587.56

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

Scenario

Other (please describe above)

Platform

Windows

Select on which network interface to search

Description

Hi,
is there any chance to give the user the ability to select a NetworkInterface where to scan for devices?
At the moment in a Windows system with multiple interfaces, the discovery system wearch on the first (?)

Could this be implemented, or is already on?

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Windows

iOS: onDiscoveryStartFailed

Hi, is there anything I need to set up on iOS for being able to start scanning?

My code:

nsd.enableLogging(nsd.LogTopic.calls);
nsd.enableLogging(nsd.LogTopic.errors);
nsd.startDiscovery('_ds-prov._tcp').then((discovery) {
// ...
});

log output:

[MethodChannelNsdPlatform] [2022-04-25 16:50:18.712895] [calls] Call: startDiscovery {handle: d4dd15f0-6bf0-4e4f-9ba3-bf789c808402, service.type: _ds-prov._tcp}
[MethodChannelNsdPlatform] [2022-04-25 16:50:18.731574] [calls] Callback: onDiscoveryStartFailed {handle: d4dd15f0-6bf0-4e4f-9ba3-bf789c808402}

The same code works fine on Android, on iOS I receive the above log output: onDiscoveryStartFailed.

Many thanks in advance and thanks for your cool nsd library!

MacOS CFNetServiceCreateTXTDataWithDictionary can't parse large Value (more than 255 bytes)

Description

flutterTxtToNativeTxt CFNetServiceCreateTXTDataWithDictionary(nil, nativeData as CFDictionary) return nil,

raw data is
{"accessKey":"","extra":"xxxxxxxx~~~~~~~"}

let nativeData : [String:Data]  = flutterTxt.compactMapValues { $0?.data }.mapValues { data in
        let str = String(data: data, encoding: String.Encoding.utf8)
        print("str;;;\(str!)")
       return data
}

==>>str;;;203713

str;;;eyJjaXBoZXJUZXh0IjoiM3B4eGxoTXFQRkthZm1JSmU0TzZPWU8zdVNsWkJZVXpTc2pjMEVoS1UyMFgvekJpdkN2dnZ0cldTWHdpY2JjMFBQa2ltVTFVWGltQ0l0eUVBTVo3T1NIVmxxK3dTVlZ4ZFdXSEJMODBNWEt1dkdYbmt5T3pMZUk5WGJPeENpNGxyMUFvS3lKNFdZZzNrdytyR1hVT0dZK3k1MFh6eUU4TnA4UVlsWXRUZGY2WU5hOGRwVkpWekJ0UHRHbXFnVitEbmtJTDFiTmpqT0dRNm14NmVmWW1NcmhYMHdiSDlLamE0WVMzS0U1TG1oWEk4bENXV0UxZmRwVVF5c0pHdWJHenB0OThVeVJpdU5zTjZrWjUvUzROQmtOTjBCR3VZU29pektuWVFibG92ckt3SUtQOG9aWW1NSnpuWWVQSjJVd3E3Qm1BSDlzV2cvc2UxOFVRUkpjUzhtT1g5WHluWnZWaUt5TlhYREl4eE9qSFNuZzRTNzRZNlpGTXhuZFNETkkwaldvN0pFVFF5bmx0NWR1T3VRT0NhU2RSL0pPdEc5RStiSDI0aTVBS3B3ZmxFajJURS8xR3I0TFJkSm53dWlmVmdNSE82Ti8xc21XNkZtN08iLCJtYWMiOiJXcTJGRDRpQ3A4N0d4c01yb0I1ZURBPT0iLCJub25jZSI6IkZzQTVWbTgrWlI1NGNlaEUyQ2hOV010d0t4blRNcForIn0=

print("CFNetServiceCreateTXTDataWithDictionary==>\(CFNetServiceCreateTXTDataWithDictionary(nil, nativeData as CFDictionary))")

==>>nil

need to be split into many small values
like
{"ac":"less than 255","bc":"less than 255","cd":"less than 255","ef":"less than 255"}

Scenario

Use the plugin in my own application via Flutter dependency

Platform

macOS

Error Uint8List not found

Description

gambar
Hi, i got a error when running my application when using nsd package, errors may be is missing import of dart:typed_data on package nsd_platform_interface

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Windows

mDNS Service registered with nsd not resolving correctly.

Description

Hello 👋


I hope you guys are doing well 😄

I'am oppening an issue since i couldn't find a solution myself and i'am pretty sure it's not Client or Firewall related.
Basically i'am publishing a service with nsd but can't resolve the .local domain from client computer.
I'am able to see the service with mdns-scan (linux) but can't resolve with a ping command.

I tried with and without manually setting addresses list in nsd but i had the same result.

I can resolve my ESP8266 & ESP32 MDNS Services fine , only mdns services registered with nsd on my Android Tablet have issues resolving on any computer on my lan.

With manual addresses list

void example() async {
  for (var interface in await NetworkInterface.list()) {
        if (interface.name == "wlan0") {
          for (var addr in interface.addresses) {
            if (addr.type.name == "IPv4" && addr.isLoopback == false) {
              print(addr.address);
              register(
                Service(
                    name: '4022d8feb94cdomotika',
                    type: '_servicename._tcp',
                    addresses: [addr],
                    port: 36080),
              );
            }
          }
        }
}

Without manual addresses list

void example() {
    register(
      Service(
          name: '4022d8feb94cdomotika',
          type: '_servicename._tcp',
          port: 36080
      ),
    );
}

Thanks , and have a nice day 👋

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.