node_mdns
node_mdns copied to clipboard
Duplicate Discovery, Including Local
Hi all,
I finally got through the hoops on getting this working on my Raspberry Pi 3, running Raspbian Jesse. I dug this out of the issues to get it working.
var sequence = [
mdns.rst.DNSServiceResolve(),
'DNSServiceGetAddrInfo' in mdns.dns_sd ?
mdns.rst.DNSServiceGetAddrInfo() :
mdns.rst.getaddrinfo({families:[0]}),
mdns.rst.makeAddressesUnique()
];
var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});
I register this event handler:
browser.on('serviceUp', function (service) {
console.log("service up: ", service);
});
... and I actually find stuff on my network (like an HP printer). The odd thing, to me, is that I seem to get everything in duplicate. And, to boot, I also see the service that I'm advertising from the same program. Is the library supposed to discover services running locally? Any way to prevent it from doing that? Here's an example of the discoveries on my network:
service up: { interfaceIndex: 3,
type:
ServiceType {
name: 'http',
protocol: 'tcp',
subtypes: [],
fullyQualified: true },
replyDomain: 'local.',
flags: 2,
name: 'raspberrypi',
networkInterface: 'wlan0',
fullname: 'raspberrypi._http._tcp.local.',
host: 'raspberrypi.local.',
port: 3000,
addresses: [ '192.168.1.78' ] }
service up: { interfaceIndex: 3,
type:
ServiceType {
name: 'http',
protocol: 'tcp',
subtypes: [],
fullyQualified: true },
replyDomain: 'local.',
flags: 2,
name: 'raspberrypi',
networkInterface: 'wlan0',
fullname: 'raspberrypi._http._tcp.local.',
host: 'raspberrypi.local.',
port: 3000,
addresses: [ '192.168.1.78' ] }
service up: { interfaceIndex: 3,
type:
ServiceType {
name: 'http',
protocol: 'tcp',
subtypes: [],
fullyQualified: true },
replyDomain: 'local.',
flags: 2,
name: 'HP LaserJet 200 color M251nw (1341D0)',
networkInterface: 'wlan0',
fullname: 'HP\\032LaserJet\\032200\\032color\\032M251nw\\032\\0401341D0\\041._http._tcp.local.',
host: 'NPI1341D0.local.',
port: 80,
addresses: [ '192.168.1.122' ] }
service up: { interfaceIndex: 3,
type:
ServiceType {
name: 'http',
protocol: 'tcp',
subtypes: [],
fullyQualified: true },
replyDomain: 'local.',
flags: 2,
name: 'HP LaserJet 200 color M251nw (1341D0)',
networkInterface: 'wlan0',
fullname: 'HP\\032LaserJet\\032200\\032color\\032M251nw\\032\\0401341D0\\041._http._tcp.local.',
host: 'NPI1341D0.local.',
port: 80,
addresses: [ '192.168.1.122' ] }
The first two and the next two seem like pure duplicates to me... am I missing something?
The odd thing, to me, is that I seem to get everything in duplicate
Yes, that's odd. It most likely is yet another raspbian networking issue. I don't know raspbian first hand so I can't help, I'm afraid. I could rant a bit about the crazy stuff I hear about the raspbian network stack if it helps? It definitely is not normal.
And, to boot, I also see the service that I'm advertising from the same program.
That on the other hand is perfectly normal and by design (of the underlying system service). The name
property is unique on the local network... #166 has some code.