searchForBrowsableDomains fails on macOS 10.12

I have an app which uses NSNetServiceBrowser to search for mDNS services.

It has been working great up until I updated my iMac to macOS Sierra (10.12)


I declare an NSNetServiceBrowser like this:

@property (strong, nonatomic) NSNetServiceBrowser *serviceBrowser;


and then initialise it like this:

_serviceBrowser = [[NSNetServiceBrowser alloc] init];
_serviceBrowser.delegate=self;


and then start it like this:

[_serviceBrowser searchForBrowsableDomains];


But I do not get any call backs to

- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindDomain:(NSString *)domainString moreComing:(BOOL)moreComing


Instead in the console I get these errors:

2016-10-03 12:35:11.467503 mDNS Hunter[70508:9564329] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1

2016-10-03 12:35:12.468017 mDNS Hunter[70508:9564329] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2

2016-10-03 12:35:13.468456 mDNS Hunter[70508:9564329] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3

2016-10-03 12:35:14.469617 mDNS Hunter[70508:9564329] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8 Err:-1 Errno:1 Operation not permitted


So I wonder - do I need to add some new entries to my entitlements or something to make this work with Sierra?

Or is there something else going on here?


Thanks in advance!

Kenny.

Replies

2016-10-03 12:35:14.469617 mDNS Hunter[70508:9564329] dnssd_clientstub
ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8
Err:-1 Errno:1 Operation not permitted

This error indicates that the Bonjour client libraries (

<dns_sd.h>
, which is what’s underlying NSNetServiceBrowser) is unable to talk to the Bonjour daemon (
mDNSResponder
). There’s two possibilities:
  • something has gone wrong system wide

  • something is causing problems for just your app

With regards the first, what do you see when you try this operation using

dns-sd
.
$ dns-sd -F
Looking for recommended browsing domains:
DATE: ---Wed 05 Oct 2016---
9:10:43.935  ...STARTING...
Timestamp    Recommended Browsing domain
9:10:43.936  Added                          local
^C

And what does this show:

$ ls -lh /var/run/mDNSResponder
srw-rw-rw-  1 root  daemon    0B 30 Sep 07:43 /var/run/mDNSResponder

With regards the second possibility, the most obvious reason for your app having problems is the app sandbox. Is your app sandboxed? If so, what happens if you temporarily disable the sandbox?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"