4

I am trying to run a HTTP server in my LAN and want to access it by using a browser on another desktop machine. As I do not like typing the IP address and port manually I tried setting up a mDNS using jmDNS.

        String type = "_http._tcp.local.";
        jmdns = JmDNS.create();
        jmdns.addServiceListener(type, listener = new ServiceListener() {
            @Override
            public void serviceResolved(ServiceEvent ev) {
                Log.d(LogTag.SERVER, "Service resolved: " + ev.getInfo().getQualifiedName() + " port:"
                        + ev.getInfo().getPort());
            }

            @Override
            public void serviceRemoved(ServiceEvent ev) {
                Log.d(LogTag.SERVER, "Service removed: " + ev.getName());
            }

            @Override
            public void serviceAdded(ServiceEvent event) {
                // Required to force serviceResolved to be called again (after the first search)
                jmdns.requestServiceInfo(event.getType(), event.getName(), 1);
            }
        });
        serviceInfo = ServiceInfo.create(type, NAME, PORT, "test service");
        jmdns.registerService(serviceInfo);

The mDNS entry shows up on ZeroConf Browser app just fine. The server is reachable by IP and port just fine.

ZeroConf Browser Screenshot

On Windows 7 typing the name with the .local TLD (= http://roseblade.local/) into any address bar (Firefox, Chrome, Safari, IE) does not do much and from what my research shows is pretty much a futile task anyway. I installed Apple Bonjour but that only help running Hobbyist Software's Bonjour Browser. As far as Linux goes I tried the same with elemantaryOS and Midori but that also did not work. OSX or iOS is currently not available to me.

How can I get the resolution of the .local address to work in my browser (Firefox, Chrome, whatever on Linux, OSX or Windows7)? Am I doing something wrong? At this point I would just like to verify that mDNS can work like that on a system.

Pointers to material on the issue are also appreciated.

Lucas Hoepner
  • 1,437
  • 1
  • 16
  • 21
  • Sadly, I couldn't make it work and moved on to other stuff. Just did a quick Google Search, maybe: https://learn.adafruit.com/bonjour-zeroconf-networking-for-windows-and-linux/overview helps. – Lucas Hoepner Sep 14 '15 at 12:41

1 Answers1

2

mDNS and Bonjour can be a little confusing because they actually encompass a few different functionalities. Service discovery, which I believe is what you have implemented, is one. Resolving an address--which is what you're looking for--is separate, and needs to be solved separately. Once you have address resolution working, you can point your service discovery at the DNS records provided by your resolver.

mDNS address resolution works by multicasting a DNS query over the network. By binding to a UDP port, listening for queries, and answering them, you can provide DNS records to mDNS clients. To do this, you can use an existing mDNS server like avahi-daemon, or, if you need custom functionality or integration with your application, implement one using something like Node.js's multicast-dns.

However, in my experience, this has been rather flakey. Some network configurations interfere with mDNS resolution, as do some OSes (eg. iOS 8, see the whole debate around discoveryd vs. mDNSResponder).

Ian
  • 2,078
  • 1
  • 17
  • 27