Jmdns: Can't Resolve Service
Solution 1:
Checking out the latest source code version from the github repository did the trick. Discovering the service now works just fine on all devices. (Note: I was using JmDNS version 3.4.1 which I had downloaded from sourceforge before)
Having skimmed through the SVN history, there seem to be a couple of commits related to problems with resolving services since the 3.4.1 release.
Edit: Replaced svn with github repository since jmdns has moved there.
Solution 2:
Use JmDNS.create(InetAddress addr, String name)
instead of JmDNS.create()
. In more recent versions of Android, JmDNS needs to know more about the local device and the network interface it is listening on.
JmDNS jmdns; // somewhere global// In a background thread publicvoidbuildJmDNS() {
InetAddressaddr= InetAddress.getLocalHost();
Stringhostname= InetAddress.getByName(addr.getHostName()).toString();
try {
jmdns = JmDNS.create(addr, hostname); // throws IOException
} catch (IOException e) {
e.printStackTrace(); // handle this if you want
}
}
I had the same issue you are experiencing and this solved it for me. I have tried to find the example I had found that shows why this is necessary, but I cannot.
Post a Comment for "Jmdns: Can't Resolve Service"