becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

.watch() doesn't list all services #58

Closed lucamarogna closed 5 years ago

lucamarogna commented 6 years ago

Watch method only lists some services while using Bonjour Browser by Tildesoft (you had mention this tool somewhere) I can see them all.

I published 4 services in my NodeJS app using both https://github.com/agnat/node_mdns and https://github.com/watson/bonjour and also joking with their params, but no luck at all.

This is what Bonjour Browser sees: schermata 2017-12-01 alle 17 05 14

My services are BONJOUR test 1/2 and MDNS test 1/2.

zeroconf is used as this: let zeroconf = cordova.plugins.zeroconf;

zeroconf.watch('_smb._tcp.', 'local.', function(result) {
    let action = result.action;
    let service = result.service;
    if (action == 'added') {
        console.log('1 service added', service);
    } else if (action == 'resolved') {
        console.log('1 service resolved', service);
    } else {
        console.log('1 service removed', service);
    }
}, function(err){
    console.log("ERROR", err);
});

and, running it in a real iPod Touch 5th gen, the Safari console prints out this: schermata 2017-12-01 alle 17 09 09

As you can see zeroconf doesn't list my services.

I already tried to change ports, hostnames and service names in the Node JS app. I already tried some combination of '_smb._tcp.', 'local.'. No luck at all.

Bonus note: as you can see in Bonjour Browser, there're also 2 services registered as _teamviewer._tcp., but I can't see them using cordova.plugins.zeroconf.watch('_teamviewer._tcp.', 'local.', console.log); directly on console.

I'm feeling lost :-( Can you help me please? Thanks a lot.

becvert commented 6 years ago

ok.. that's annoying could you install a zeroconf browser app on your ipod and check that you see all the services in it? (Flame Services Browser for instance)

lucamarogna commented 6 years ago

UPDATE: running the same code on the iOS simulator, I got these from the console:

2017-12-01 18:29:45.242087+0100 m-frame[16702:587662] THREAD WARNING: ['ZeroConf'] took '95.268066' ms. Plugin should use a background thread.
2017-12-01 18:29:45.397604+0100 m-frame[16702:587662] service added EPSON WP-4535 Series
2017-12-01 18:29:45.399945+0100 m-frame[16702:587662] service added Mac mini
2017-12-01 18:29:45.401882+0100 m-frame[16702:587662] service added BONJOUR test 1
2017-12-01 18:29:45.402090+0100 m-frame[16702:587662] service added MDNS test 2
2017-12-01 18:29:45.444354+0100 m-frame[16702:587662] service resolved EPSON WP-4535 Series
2017-12-01 18:29:45.445042+0100 m-frame[16702:587662] service resolved Mac mini
2017-12-01 18:29:45.446439+0100 m-frame[16702:587662] service resolved MDNS test 2
2017-12-01 18:29:51.066513+0100 m-frame[16702:587662] service added GranGuardia
2017-12-01 18:29:51.104781+0100 m-frame[16702:587662] service resolved GranGuardia

So it does find them! All! But why on real device it doesn't ? Need to further investigate...

lucamarogna commented 6 years ago

Ok, installed "Discovery - DNS-SD Browser" app by the previous mentioned Tildesoft. My services are not found! Also TeamViewer ones. It lists only the same you see also with your plugin.

Any idea on why it happen and how to resolve? Already tried to switch on/off the WiFi.

kaichancoder commented 6 years ago

I too get intermittent availability. On my mac using Bonjour Browser I always see the services. On my android phone using the "ZeroConf Browser" app I too always see the services, but using the app "Service Browser", the services sometimes appear initially and then disappears. And finally using "cordova-plugin-zeroconf" I sometimes see the services and sometimes not, however it always says "added", I'm looking for "resolved" because I need the IP address.

kaichancoder commented 6 years ago

Just to answer my own question, you need to close the Zeroconf object if you want the see the "resolved" object again.

becvert commented 5 years ago

Closing old issue. Feel free to reopen.