Skyost / Bonsoir

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.
http://bonsoir.skyost.eu/
Other
100 stars 43 forks source link

iOS cannot discover a host running on Windows #83

Open gomaze1031 opened 5 months ago

gomaze1031 commented 5 months ago

Describe the bug iOS cannot discover a host running on Windows.

I tested as follows:

  1. Connect all devices to the same WiFi (and checked they are assigned to 192.168.0.x)
  2. Start hosting on Windows and macOS
  3. iOS discovers a host running on macOS
  4. iOS cannot discover a host running on Windows
  5. Android discovers a host running on macOS and Windows

Version info:

FYI, there is no errors or other logs printed. Not sure it is a bug. Thanks for your nice work!

Skyost commented 5 months ago

Are you sure you're discovering the correct type ? Do you have a snippet or something ?

gomaze1031 commented 4 months ago

I think I discovered the correct type. Here are some snippets.

startDiscovery()

_dnsHost = BonsoirBroadcast(
  service: BonsoirService(
    name: "my_bonsoir_server",
    type: "_dns-service._tcp",
    port: 56000,
  ),
);

await _dnsHost?.ready;
await _dnsHost?.start();

startScan()

BonsoirDiscovery discovery = BonsoirDiscovery(type: "_dns-service._tcp");
_mDnsDiscovery.discovery = discovery;
await discovery.ready;

discovery.eventStream!.listen((event) async {
  if (event.type == BonsoirDiscoveryEventType.discoveryServiceFound) {
    debugPrint('Service found : ${event.service?.toJson()}');

    if (event.service is ResolvedBonsoirService) {
      ...
      return;
    }

    // Should be called when the user wants to connect to this service.
    await event.service!.resolve(discovery.serviceResolver);
  } else if (event.type == BonsoirDiscoveryEventType.discoveryServiceResolved) {
    debugPrint('Service resolved : ${event.service?.toJson()}');
    ...
  } else if (event.type == BonsoirDiscoveryEventType.discoveryServiceLost) {
    debugPrint('Service lost : ${event.service?.toJson()}');
    ...
  }
});

await discovery.start();

Not sure it helps you but this is all I've got.

Skyost commented 4 months ago

Side question: when the event.type is "discoveryServiceFound", event.service can be "ResolvedBonsoirService"?

Nop !

jaween commented 4 months ago

I am running into this same issue:

Versions:

Skyost commented 3 months ago

Hey,

This could be the same problem than https://stackoverflow.com/questions/60925721/my-ios-macos-devices-are-unable-to-resolve-my-bonjour-zeroconf-service-created-o. Does it work with a ResolvedBonsoirService ?

jaween commented 3 months ago

(Sorry maybe I'm misunderstanding)

With the link it looks like they used an npm package to broadcast a bonjour service which iOS discovered sucessfully, but couldn't resolve it without an extra parameter in the broadcast. But in our case iOS is not even discovering the service.

ResolvedBonsoirService works with the discovered Mac and Linux services, and I assume if the Windows service was discovered, it would work too.

Skyost commented 3 months ago

You're right, I've misread the SO post. I'll continue to investigate on my side, but feel free to post here if you got something new.