1

I'm looking into DNS based service discovery in Windows 10 and found this video from Build. The only change I made to discovery was changing the service name to "_ipp._tcp". However I don't get any hits even though I know I have > 15 IPP enabled printers on the network (I can successfully identify these using the ipptool, IOS and Android code).

I've checked and double checked for typos. I've included all networking capabilities in the appxmanifest file.

Here's my code, pretty straight forward:

public sealed partial class MainPage : Page
{
    static Guid DnsSdProtocol = new Guid("{4526e8c1-8aac-4153-9b16-55e86ada0e54}");
    string queryString = "System.Devices.AepService.ProtocolId:={" + DnsSdProtocol + "} AND " +
        "System.Devices.Dnssd.Domain:=\"local\" AND System.Devices.Dnssd.ServiceName:=\"_ipp._tcp\"";

    DeviceWatcher watcher;

    public MainPage()
    {
        this.InitializeComponent();
    }

    private void button_Click(object sender, RoutedEventArgs e)
    {
        watcher = DeviceInformation.CreateWatcher(queryString,
            new String[]
            {
                "System.Devices.Dnssd.HostName",
                "System.Devices.Dnssd.ServiceName",
                "System.Devices.Dnssd.TextAttributes",
                "System.Devices.IpAddress" },
            DeviceInformationKind.AssociationEndpointService
            );

        watcher.Added += Watcher_Added;
        watcher.Start();
    }

    private void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
    {
        System.Diagnostics.Debug.WriteLine("found device");
    }
}

Does anybody else have experience with this and can help figure out why no devices are found? Is my query correct? Do I need to do anything else when setting up the DeviceWatcher?

update
I've verified the requests are being created since they are showing up in Wireshark. They look to be identical to other mdns requests being created. I've also verified I can create SSDP requests that return discovered devices so I doubt it's an issue with networking permissions via app capabilities.

earthling
  • 5,084
  • 9
  • 46
  • 90

1 Answers1

0

Try using the watcher.Updated handler. Even if it is empty, the presence of an Updated handler can cause the Added handler to be triggered.

JvJ
  • 112
  • 3
  • As you might guess. The DeviceInformation.CreateWatcher works, but when you try to use DeviceInformation.FindAllAsync you got empty result. I did not find any solution. – steam3d Oct 28 '22 at 16:14