Bonjour Debugging: Why can't I connect to my app?

If you're having trouble connecting to your application with Reveal, the following steps may help diagnose if the issue lies with Bonjour's Service Disovery.

Ensure Reveal is being linked correctly.

The first thing to do is check the Reveal library is linked into your app correctly. When Reveal starts it logs the following message to the console:

2014-10-13 22:11:58.228 RevealSample[49943:70b] INFO: Reveal Server started (Protocol Version 18).

If you don't see this message, Reveal is not starting (or you have disabled Reveal's logging via its API). See the Integration guide in the Reveal help menu for details on how to link with the Reveal library correctly.

Reveal is Starting but I still can't connect...

Here are some tips on how to debug network issues relating to Bonjour & Reveal:

Reveal Bonjour Service Discovery

Reveal publishes itself as a Bonjour service from within your iOS app using the service type _reveal._tcp. You can use the dns-sd tool on your Mac to list any apps currently running the Reveal framework.

To do so, open Terminal and issue the following command:

dns-sd -B _reveal._tcp local

You should see output similar to this:

Browsing for _reveal._tcp.local
DATE: ---Tue 07 Oct 2014---
10:42:34.746  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
10:42:34.746  Add        3   4 local.               _reveal._tcp.        Reveal--bcea6fb9
Note: dns-sd doesn't exit immediately. If it doesn't print out much output it might look like it has just locked up. It has not: you need to type Control-C to quit. This is also true of the other dns-sd commands listed below.

You can see in the example above that there is one app being advertised with the instance name Reveal--bcea6fb9. The code at the end of the Instance Name is used to make each Reveal app on your network be unique. Your app's Instance Name name will be different.

Press Control-C to stop browsing for services with dns-sd.

Now we need to find out what port your app is listening on for Reveal connections. You can do this using the following command:

dns-sd -L Reveal--93cf9fec _reveal._tcp.

You will need to substitute your own app's Instance Name (which you got from the previous command) when using this command.

Here is the expected output from dns-sd:

Lookup Reveal--bcea6fb9._reveal._tcp..local
DATE: ---Tue 07 Oct 2014---
10:47:29.923  ...STARTING...
10:47:29.924  Reveal--bcea6fb9._reveal._tcp.local. can be reached at localhost.:51441 (interface 0) Flags: 2
 devName=iPhone\ Simulator devSysVer=7.1 appName=RevealSample devSysName=iPhone\ OS isSim=true devLocalModel=iPhone\ Simulator appBundleId=com.ittybittyapps.RevealSample protoVer=14

Type Control-C to stop dns-sd.

In the example above you will see that the app is listening for connections on port 51441 and host localhost. The Reveal framework randomly picks a port number so it will be different each time you run your app. When run in the iOS Simulator the Reveal framework always binds to localhost ( When run on an actual iOS device it will bind to the public network interfaces on that device.

The host may also be listed as an IP address rather than as a hostname.

Note: The dns-sd commands above should not give you errors and should not need to be run as 'root' (or via sudo). If you are getting errors, there may be something wrong with your network setup: Bonjour may be blocked, or the Bonjour daemon (mDNSResponder) is not running correctly. Try rebooting your Mac if mDNSResponder is not running.

Graphical Bonjour Browser

Kevin Ballard at TildeSoft provides a simple Mac GUI for showing all the Bonjour services being advertised on your network. You can use Discovery to try and get at the same information we collected via the dns-sd command above, without having to use the command line. Kevin has also published a similar app for the iPhone which is available on the iOS App Store for free.

Resolving localhost

To successfully discover apps running in the Simulator, Reveal needs to be able to resolve localhost host name. To check this, open Terminal and issue the following command:

dns-sd -G v4 localhost

You should immediately see output such as this:

DATE: ---Wed 03 Oct 2018---
11:36:46.010  ...STARTING...
Timestamp     A/R    Flags if Hostname      Address      TTL
11:36:46.011  Add        2 -1 localhost.    1

Once again, press Control-C to stop dns-sd. If you don't see this output (a successful resolution as, it may indicate that localhost entry is missing from your /etc/hosts file. This file should contain contents similar to the following, and as noted must contain entries for localhost:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost broadcasthost
::1             localhost

Testing a Connection to Reveal's Server

Now that we know the host and port that the Reveal server is listening on, we can send a test request to it. You do this using the curl command line utility.

Given the details shown in the examples above, I would use the following command to test a connection to the Reveal server embedded in my app:

curl -s -D - http://localhost:51441/application -o /dev/null

This should give output similar to:

HTTP/1.1 200 OK
Reveal-Protocol-Version: 14
Accept-Ranges: bytes
Content-Length: 945851
Content-Type: application/json; charset=utf-8
Date: Mon, 06 Oct 2014 23:58:44 GMT

If you see a response similar to this, the connection to Reveal is working as expected!

Still Having Issues?

Try rebooting your iOS device, and your Mac — we've encountered a number of connection issues that have gone away after a quick reboot.

A common problem that's we encounter is users whose iOS devices and Mac are on different networks. There are a couple of things you can try to diagnose if this is a problem:

  1. If your Mac is connected via ethernet, try unplugging it and connecting to the same Wi-Fi network as your iOS device.
  2. Try setting up Internet Sharing on your Mac via Wi-Fi, and connect to it using your iOS device.

One other problem that we're aware of is related to HSTS cookies: if you have ever tried running a local web server on your Mac with HSTS rules configured, the HTTPS redirect may have been remembered, which stops Reveal from connecting to its Server correctly. If you can see your app in Reveal's connections list, but inspecting it fails, check the console logs by running the Console app, filtering by "Reveal" and looking for messages that appear when you try connecting to your app. This may include a message like the following:

ERROR: Failed to refresh application state:
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
UserInfo={ <...>, NSErrorFailingURLStringKey=https://localhost:54017/application, <...> }

If you see https in the NSErrorFailingURLStringKey parameter, it means that a HSTS rule has been triggered for Reveal attempting to connect to the local server. In this case, try deleting the ~/Library/Cookies/HSTS.plist file to reset HSTS cookies, restarting Reveal and trying again.

If none of the suggestions above allow you to successfully connect to your app from Reveal, you may need to talk to your network administrator about allowing access for Reveal to communicate on your network.

If this article hasn't helped you solve your Bonjour-related issues please let us know. Including the output from the commands shown above in your support request will help us debug the problem.