sebastianhaberey / nsd

Flutter Network Service Discovery (NSD) Plugin
66 stars 33 forks source link

NsdError (message: "missing required configuration #47

Closed ameetaujla closed 1 year ago

ameetaujla commented 1 year ago

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

Erhannis commented 1 year ago

(OP originally posted this issue in my library that depends on nsd, so I pointed to this repo, but also I've done some digging and figured it's more relevant to post here.)

After about half an hour of nothing turning up in google, I finally ran across this: https://developer.apple.com/forums/thread/664548 TL;DR: try putting an extra period at the end of the service in the info.plist file: _http._tcp. If that doesn't work, I guess read the full thread and see if any of it helps. I may not be available for about two weeks, so good luck, and let us know if it worked.

ameetaujla commented 1 year ago

Thank you bro.

let me try this and get back to you in a few minutes.

ameetaujla commented 1 year ago

No bro nothing works.. it still shows the same error.

Erhannis commented 1 year ago

Bummer. You read the thread? Did you see any errors in Console, like "App Info.plist(NSBonjourServices) does not allow..."? Come to think of it...my library takes the service id you give it and registers it as _SERVICEID._tcp, so e.g. _foo._tcp. This could be my fault for not reading the NSD instructions carefully enough, and not making my instructions match sufficiently. If you haven't, try swapping in your service ID in the info.plist. If that doesn't work, try adding the extra period. If that doesn't work, I guess check the Console to see what service id it's expecting? Maybe something else happens to the service id after my app is done with it. Lemme know what happened.

ameetaujla commented 1 year ago
static const SERVICE_ID = "MYID";
  Future<void> STARTSERVER() async
  {
    var zc = ZeroConnect(localId: "SAMSUNG2");
    await zc.advertise(serviceId: SERVICE_ID, callback: (messageSock, nodeId, serviceId) async {
      print("got message connection from $nodeId");

      var str = await messageSock.recvString(allowMalformed: true,tryHard: true);

      print(str);

      await zc.close();
} 

this is my code and this is my info.plist

<key>NSLocalNetworkUsageDescription</key>
    <string>Required to discover local network devices</string>
    <key>NSBonjourServices</key>
    <array>
        <string>_http._tcp.</string>
    </array>

when i click on button to execute this code it shows [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: NsdError (message: "missing required configuration", cause: internalError)

this error

ameetaujla commented 1 year ago

I am new to Flutter and IOS. I don't know to use info.plist file please help

Erhannis commented 1 year ago

Try changing "_http._tcp." to "_MYID._tcp". If it doesn't work, try "_MYID._tcp.". If that doesn't work, then open the Console app on the mac and look at the phone's logs, like this: https://support.apple.com/guide/console/log-messages-cnsl1012/mac Look for a line like the forum said, like "App Info.plist(NSBonjourServices) does not allow '_myprotocol._http._tcp.' for (My App)". Then copy the stuff in quotes into your info.plist .

Sorry, I don't have a mac to debug this myself.

ameetaujla commented 1 year ago

no problem bro. I am testing it and send you complete logs in a few minutes. Thank you soo much for the help.

ameetaujla commented 1 year ago

Wow, great help bro. it got fixed by changing "_http._tcp." to "_MYID._tcp". really sorry for my silly mistake. Thank you so much <3

Erhannis commented 1 year ago

Awesome, glad it worked. I'll update my README accordingly. Uh, sorry NSD people. @ameetaujla , if it works, go ahead and close the issue. Good luck with your project.

sebastianhaberey commented 1 year ago

@Erhannis no problem, it doesn't hurt to have an issue for this, maybe it will help other people with similar issues 🙂 I'm closing it now, since it seems to be resolved.