vstirbu / ZeroConf

ZeroConf plugin for Cordova/Phonegap 3.0
MIT License
38 stars 21 forks source link

Can't find my http server on network #24

Closed laughinglion closed 6 years ago

laughinglion commented 7 years ago

Hi, I'm trying to detect my http web service broadcasted on my network, but the watch callback is never fired: ZeroConf.watch('_http._tcp.local.', function (result) { console.log('ecs ' + JSON.stringify(result)); });

Android Studio console shows: 07-13 09:18:40.469 4281-4281/za.co.myapp.print V/ZeroConf: Initialized 07-13 09:18:41.443 4281-4338/za.co.myapp.print D/ZeroConf: Setup watcher 07-13 09:18:41.452 4281-4338/za.co.myapp.print D/ZeroConf: Watch _http._tcp.local. 07-13 09:18:41.452 4281-4338/za.co.myapp.print D/ZeroConf: Name: 192-168-83-101.local. host: 192-168-83-101.local.

I can see it advertised if I use the dns-sd tool: dns-sd -Z _http._tcp

_http._tcp PTR Corne2-PC._http._tcp Corne2-PC._http._tcp SRV 0 0 8080 Corne2-PC.local. ; Replace with unicast FQDN of target host Corne2-PC._http._tcp TXT "product=Print Server API 0.1.0 "

The web server is on nodejs and advertised with: var ad2 = mdns.createAdvertisement(mdns.tcp('http'), 8080, {txtRecord: {product: 'Print Server API 0.1.0 '}}); ad2.start();

Any suggestions?

vstirbu commented 7 years ago

Can you provide more info about your setup, e.g. device used, network configuration, etc.?

Are you able to see the service using something like this: https://play.google.com/store/apps/details?id=com.melloware.zeroconf&hl=en?

laughinglion commented 7 years ago

Hi, sorry for late reply.

I tried the library from my Samsung S5 phone and Nexus 7 2012 tablet.

I tried the app above in the link you gave with my Samsung phone and it successfully finds my custom http server as well as my custom ipp service.

The service runs on my computer which is wirelessly connected to my Internet router, the phone connects to the same wifi network.

jcrosby10 commented 6 years ago

I am having the same issue, my callback is not being called. My log is showing


03-07 14:50:42.686 6401-6503/? D/ZeroConf: Hostname android-64aa88813184d8e6
03-07 14:50:42.686 6401-6503/? V/ZeroConf: Initialized
03-07 14:50:42.686 6401-6503/? D/ZeroConf: Watch _http._tcp.
vstirbu commented 6 years ago

timakeystore.jar is not part of this plugin.

jcrosby10 commented 6 years ago

Yes I am not worried about that line. Its the 3 above because my callback is never called with a result. I just did a search in the log for zeroconf and this is what was shown. It appears that the code is initializing and starts the process of watching. But I never get a response back.

jcrosby10 commented 6 years ago

I updated the comment to be more relevant.

vstirbu commented 6 years ago

The plugin works only when you have network interfaces supporting multicast. Cellular is not one of them. What network interfaces you have active?

jcrosby10 commented 6 years ago

My tablet is connected to a wifi network. There is a another device on that network I need to scan for and detect it. This app was originally set up to use the npm module bonjour which is another multicast detection service. So this should work. I had to switch because bonjour doesn't work on mobile.

jcrosby10 commented 6 years ago

Well I found out somehow I am using a different plugin. cordova-plugin-zeroconf. I was searching Google and found this and thought it was the same plugin as the names are very similar.

vstirbu commented 6 years ago

Over reliance on Google, it seems... but now that you are here, you can use plugin that actually works 😁