becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

Service not found on android when name is ip address #6

Closed kevin-dp closed 8 years ago

kevin-dp commented 8 years ago

Hi,

I'm using the plugin for one of my projects, until now I tested it on iOS and it works fine. However, on Android (Nexus 5 phone) the published services are not found.

Because I don't want my app to publish accidentally a service with the same name as another one I'm using the machine's ip address as name, hence it will be unique. But Android refuses to publish them.

I made a minimal example that shows the problem :

var zeroconf = cordova.plugins.zeroconf;
zeroconf.watch('_http._tcp.local.', function(result) { 
    // Display result.service.name --> Displayed on iOS but not on Android
});

// If below i provide as name '192/168/0/205' it also works on Android, but with the points not...
zeroconf.register('_http._tcp.local.', '192.168.0.205', 80, {
        'foo' : 'bar'
});
becvert commented 8 years ago

I'll have a look

becvert commented 8 years ago

can you try "192.168.0.205._http._tcp.local"?

else report the issue with the jmdns library.

I'm trying get a more recent version of that library.

as a workaround, you could also publish a more user-friendly name such as a host name or device name cordova-plugin-device-name

kevin-dp commented 8 years ago

I tried with "192.168.0.205._http._tcp.local" but that's not working either. I could indeed use a more user-friendly hostname, although I don't understand why using that name does not work as it simply is a string like every other name.

Thanks for your time.

becvert commented 8 years ago

I agree with you. I don't understand why it is not working. I believe it is an issue with the jmdns library.

kevin-dp commented 8 years ago

Note that a few years ago a master student at our university did some research about the topic. He found out that Android's official NSD support seemed to be more stable than jmdns, and he used it in his app, with success. It could be nice to test this one :)

Thanks for your plugin and the support you provide. You did an awesome job!

becvert commented 8 years ago

But API 16 is required for NSD. I think I'll try it anyway. And provide both implementations (JmDNS and NSD).

Also note that I think both JmDNS and NSD prevent collisions by incrementing service names. eg "NsdChat" to "NsdChat (1)"

kevin-dp commented 8 years ago

Indeed.

I would be very interested for the NSD implementation. Keep me in touch :)

becvert commented 8 years ago

I won't (or can't) fix your issue But an NSD implementation (#7) or a more recent version of JmDNS might fix this problem. Closing now. Thanks.

becvert commented 8 years ago

JmDNS seems to have fixed the issue https://github.com/jmdns/jmdns/blob/master/CHANGELOG.txt

problem with . in name

becvert commented 8 years ago

I upgraded JmDNS. I think it fixes the issue.