0

I've been trying to use Onovotny's Zeroconf package in my 8.1 phone app. It discovers the service that I'm looking for but none of the TXT records come back.

In iOS I'm using NSNetServiceBrowser and for Android, JmDNS. Both give me everything I need, so I know it isn't the service.

This is the code I'm using:

public async Task StartDiscovery()
{
    Action<IZeroconfHost> callback = new Action<IZeroconfHost>((IZeroconfHost host) => 
    {
        Debug.WriteLine(host.Services.Count); 
    });

    IReadOnlyList<IZeroconfHost> results = 
        await ZeroconfResolver.ResolveAsync(SERVICE_TYPE, new TimeSpan(0, 0, 10), 4, 2000, callback);
    Debug.WriteLine(results);
}

When I set a break point in my callback, this is what I see. visual studio screenshot

I'm not sure if I'm doing something wrong or if the library doesn't handle my situation. Either way, any help would be greatly appreciated.

Note: I posted an issue at the Zeroconf GitHub repo a couple of days ago but haven't received a response.

Jeremy Roberts
  • 751
  • 1
  • 5
  • 13

1 Answers1

0

Instead of using the NuGet package, I pulled the code into my project and set a few breakpoints.

In ZeroconfResolver.cs, when I change Additionals to Answers I get the txt records for my service.

ZeroconfResolver.cs line 249

// Get the matching service records
var serviceRecords = response.Answers
    .Where(r => r.NAME == ptrRec.PTRDNAME)
    .Select(r => r.RECORD)
    .ToList();

Edit: Merging the Additionals and Answers lists is a better way to go.

List<RR> resourceRecords = new List<RR>().Union(response.Answers).Union(response.Additionals).ToList();
// Get the matching service records
var serviceRecords = resourceRecords
    .Where(r => r.NAME == ptrRec.PTRDNAME)
    .Select(r => r.RECORD)
    .ToList();
Jeremy Roberts
  • 751
  • 1
  • 5
  • 13
  • If you are discovering public services, it is a good idea to look at both additionals and answers because I have noticed that some services use one and some use the other. – Jon Apr 13 '15 at 19:53
  • Thanks, I've merged the two lists so that it works with both. – Jeremy Roberts Apr 13 '15 at 21:31