mdns-js / node-mdns-js

Pure JavaScript/NodeJS mDNS discovery implementation.
Apache License 2.0
161 stars 60 forks source link

Devices not being emitting #47

Open johnnyman727 opened 9 years ago

johnnyman727 commented 9 years ago

Hello!

This is a cross post from a Tessel issue.

Essentially, I can detect my device using the dns-sd utility on OSX but the device is not being emitted when I use this lib.

Debugging information is below:

  mdns:lib:networking interface +0ms en0 172.20.10.5
  mdns:lib:networking creating socket for +5ms en0
  mdns:lib:networking bindToAddress +7ms en0
  mdns:lib:networking sending to +6ms { address: '172.20.10.5', family: 'IPv4', port: 63685 }
  mdns:lib:networking created buffer with length +2ms 36
  mdns:outbound message +1ms 000001000001000000000000075f74657373656c045f746370056c6f63616c00000c0001
  mdns:lib:networking 172.20.10.5 sent 36 bytes with err:null +1ms
  mdns:lib:networking stopping +5s
  mdns:lib:networking socket closed +0ms { address: '172.20.10.5', family: 'IPv4', port: 63685 }

As soon as I clear my cache with the following command, it starts to work again:

sudo killall -HUP mDNSResponder
johnnyman727 commented 8 years ago

@kmpm do you have any suggestions of how we can start debugging this? We mailed out about 3k Tessels last week and as you might expect some people are having trouble detecting their Tessel on their network. Is there a way we can tell if the network is not configured properly or if the packets just aren't being received properly?

kmpm commented 8 years ago

First of all, are you using this library to detect a device on the network or advertising their presence? And as stated in the readme it might clash with existing bonjour and avahi services and bonjour is definitely running on mac.

That issue is about 2 different services listening to the same port and I haven't been able to verify if it is an issue and what to do about it if it is. But I would start there.

Also a wireshark dump would be great.

kmpm commented 8 years ago

The outgoing package has the correct contents but I see that you are excluding 0.0.0.0 in the tessel-cli code. I have seen some suggestions that you might need to use 0.0.0.0 but that might clash with any system services listening on the same port there.

johnnyman727 commented 8 years ago

First of all, are you using this library to detect a device on the network or advertising their presence?

Sorry for not being more clear! The Tessels are using dns-sd on OpenWRT to advertise. The CLI is using this library to detect their presence.

And as stated in the readme it might clash with existing bonjour and avahi services and bonjour is definitely running on mac.

How do you recommend investigating Bonjour (or Avahi)?

We're having this issue primarily on OSX from what I can tell. Here is an example of debug information from mdns-js:

INFO Searching for nearby Tessels...
mdns:lib:networking interface +5ms en0 192.168.0.114
mdns:lib:networking creating socket for +2ms en0
mdns:lib:networking bindToAddress +8ms en0
mdns-packet:lib:dns:dnsrecord new DNSRecord +1ms { name: 'tessel.tcp.local',
type: 12,
class: 1,
ttl: 3600,
isQD: true }
mdns-packet:lib:dns:dnspacket 1 records in question +4ms
mdns-packet:lib:dns:dnspacket 0 records in answer +1ms
mdns-packet:lib:dns:dnspacket 0 records in authority +1ms
mdns-packet:lib:dns:dnspacket 0 records in additional +0ms
mdns-packet:lib:dns:dnsrecord #write() type: PTR, flag:0 class:IN, withLength:true +1ms
mdns-packet:lib:dns:bufferwriter #name +0ms tessel.tcp.local
mdns-packet:lib:dns:bufferconsumer new consumer of 512 bytes +0ms
mdns-packet:lib:dns:bufferwriter lastPart +3ms 3 [ '_tessel', '_tcp', 'local' ]
mdns-packet:lib:dns:bufferwriter writing part +1ms 
mdns-packet:lib:dns:bufferwriter writing part +0ms 
mdns-packet:lib:dns:bufferwriter writing part +1ms 
mdns:lib:networking sending to +0ms { address: '192.168.0.114', family: 'IPv4', port: 64671 }
mdns:lib:networking created buffer with length +1ms 36
mdns:outbound message +0ms 000001000001000000000000075f74657373656c045f746370056c6f63616c00000c0001
mdns:lib:networking 192.168.0.114 sent 36 bytes with err:0 +1ms