becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

[Android] Nullpointer exception for unwatch #48

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi,

since upgrading from version 1.2.4 to 1.2.7 android devices cannot find advertised mdns services. Error log gives me the following:

java.lang.NullPointerException: Attempt to invoke direct method 'void net.becvert.cordova.ZeroConf$BrowserManager.unwatch(java.lang.String, java.lang.String)' on a null object reference at net.becvert.cordova.ZeroConf$BrowserManager.access$700(ZeroConf.java:384) at net.becvert.cordova.ZeroConf$5.run(ZeroConf.java:276) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

I've since gone back to using 1.2.4 again. Great plugin, hope the above details suffice to solve the issue!

Regards

becvert commented 6 years ago

I'll have a look. thanks

becvert commented 6 years ago

what's your javascript code? do you call unwatch and close at the same time for instance?

ghost commented 6 years ago

Sequentially, yes: so after one another I have:

zeroconf.unwatch('_customtype._tcp.', 'local.'); zeroconf.close();

becvert commented 6 years ago

ok I see where is the problem. It'll be fixed in the next version. FYI, close should unwatch all services so you should only need to close.

ghost commented 6 years ago

Great stuff, thanks for the advice!

becvert commented 6 years ago

Please upgrade to 1.2.8 and let me know if it's better

ghost commented 6 years ago

Thanks becvert, works perfectly! (I tested on both iOS and Android). Huge performance difference for Android between 1.2.8 and 1.2.4, 1.2.8. is much faster.

becvert commented 6 years ago

Thank you 👍