NSNetService/Bonjour discovery only works on iPhone simulator

I'm working on an iPhone app that requires a basic client/server interaction model. For this I am going to use Bonjour and NSNetService, along with NSNetServiceBrowser to discover others on the same network. I have followed several different guides which more or less have the same sample code.

Relevant Server Code

...
serverName = [[UIDevice currentDevice] name];
netService = [[NSNetService alloc] initWithDomain:@"local."
                                             type:@"_myservice._tcp."
                                             name:serverName
                                             port:port];
...

The service publishes successfully, i.e. I get the netServiceDidPublish: callback

Relevant Browser Code

...
browser = [[NSNetServiceBrowser alloc] init];
[browser setDelegate:delegate];
[browser searchForServicesOfType:@"_myservice._tcp." 
                        inDomain:@"local."];
...

Now the result of all this is interesting:

  1. Running on an iPhone, the device can only see its own published NSNetService.
  2. Running on 2 iPhones, neither device can see the other's NSNetService.
  3. Running on the iPhone Simulator, it will find all NSNetServices, including its own.

Screenshot of iPhone Simulator

I'm sort of at a loss here... The simulator is working exactly as expected. However on the device it is not, I cannot get 2 different iPhones on the same WiFi to see each other, they only see themselves. Any idea what is going on here?

Answers


Turns out that the router that I'm on had an "SPI Firewall" enabled by default. Turning this off solved the problem.

One thing that I'm still curious about is: How come the requests coming from my Mac, both the iPhone Simulator and a Bonjour Browser, were able to get through this firewall but 3 different iPhones were not?


Need Your Help

find default key shortcuts in GTK

python gtk3 gtk2

Is there a way to get the default key shortcuts for common operations in GTK2/GTK3.

Devise routes to only use custom sign in page

ruby-on-rails-3 devise

I am trying to learn Devise and seem to have hit a problem that is nearly the same as many, many questions here on SO but just slightly different enough that I am not getting much traction following