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.
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.
Here are some tips on how to debug network issues relating to Bonjour & Reveal:
Reveal publishes itself as a Bonjour service from within your
iOS app using the service type
_reveal._tcp. You can
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
dns-sddoesn'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-sdcommands listed below.
You can see in the example above that there is one app being
advertised with the instance name
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
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
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
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
(127.0.0.1). 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.
dns-sdcommands 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 (
discoverydon OS 10.10 and later,
mDNSResponderon earlier OS X releases) is not running correctly. Try rebooting your Mac if
mDNSResponderare not running.
Kevin Ballard at TildeSoft provides a simple Mac GUI
for showing all the Bonjour services being advertised on your
network. You can use Bonjour Browser 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
app for the iPhone which is available on the iOS App Store for
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
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!
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:
- If your Mac is connected via ethernet, try unplugging it and
connecting to the same Wi-Fi network as your iOS device.
setting up Internet Sharing on your Mac via Wi-Fi, and connect
to it using your iOS device.
Check that you haven't removed the entries for localhost from your
/etc/hostsfile. 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. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost
If any 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.