JmDNS doesn't announce on Raspberry

244 Views Asked by At

I have trouble getting JmDNS up and running on Raspberry Pi device. The application works fine on all kinds of x86 Linuxes but when started on Raspberry (running "Raspbian GNU/Linux 8 (jessie)") services announced by it are invisible. Services announced by avahi-daemon (I start it manually) are visible so I guess there's a problem with the way JmDNS instance created

JmDNS dns = JmDNS.create(InetAddress.getLocalHost())
1

There are 1 best solutions below

1
Sam On

I had what sounds like a similar problem, JmDNS was discovering and publishing services on my 2 laptops and phone, but not my Pi.

I fixed it by commenting out all the IP addresses listed in the /etc/hosts files. After that I was able to create a JmDNS instance.

Alternatively add a line to the /etc/hosts file such as:

192.167.0.12 raspberrypi

The IP address being the one you want to select (if you know it) and "raspberrypi" being the name of your SERVICE_NAME. You can then do:

InetAddress addr = InetAddress.getLocalHost();       
String hostname = InetAddress.getByName(addr.getHostName()).toString();
jmdns = JmDNS.create(addr, hostname);