agnat/node_mdns

[question] Registration disappears after a while?

Closed this issue · 1 comments

Firstly, apologies if this is not the correct place to post this - I'm not sure where else is better, so hopefully this is fine with you.

Anyway, I'm having some issues with keeping an mDNS registration active across a network. I'm running this on a Windows 7 machine with the mDNSResponder service, node 4.4.6 with node-mdns 2.3.3, and testing using the mdnslookup tool.

Here's a server; let's call this 'machine A':

var mdns = require('mdns');
var mdnsAd;
try {
	mdnsAd = mdns.createAdvertisement(mdns.tcp('test'), 9999);
	mdnsAd.on('error', console.log.bind(console));
	mdnsAd.start();
	console.log('mDNS announced');
} catch(x) {
	console.log('Exception caught:', x);
}

Running mdnslookup -q:_test._tcp.local from another machine on the local network (let's call this 'machine B') returns a successful response. However, if I leave it for a few minutes, it stops responding (i.e. mdnslookup never finds the advertised service). No error messages ever show up with the above server (this is also the case for all the fi.

Interestingly, if I then run the same mdnslookup command on the same machine that the server is running on (machine A), it always succeeds, but furthermore, it enables the other machine on the network (machine B) to also succeed. It's as if the local query somehow refreshes the advertisement, or something, across the network. But then, after a few minutes the remote machine fails to find the advertised service again.

I've also done tests using the included mdns browser:

var mdns = require('mdns');
var browser = mdns.createBrowser(mdns.tcp('test'));

['serviceUp','serviceDown'].forEach((e) => {
	browser.on(e, function(service) {
	  console.log(e + ": ", service);
	});
});
browser.start();
console.log('browser started');

Like the mdnslookup test above, running this straight after the server starts up always succeeds on both local and remote machines, but fails on the remote machine (B) after a few minutes. Interestingly, when this 'failure' occurs, the serviceDown event doesn't fire. If I start another instance of the browser on machine B (let's call it 'browser B'), it'll hang for a while, then display a serviceDown event (i.e. it never displays a serviceUp event). This also triggers the first instance (let's call it 'browser A') to display a serviceDown event.

If I then start an instance of the browser on machine A (let's call this 'browser C'), it always works (like the mdnslookup test above), displaying a serviceUp event, and this also triggers browser B to get a serviceUp event. But rather peculiarly, browser A doesn't get the serviceUp event.

Does anyone know why the registration seems to disappear after a while, and what I can do to keep it running?
Sorry for the long post, and thanks in advance for any information!

Identified the cause to be the mDNSResponder service.

Using Apple's Bonjour package, I don't get these problems, but my open source compile does. Windows Firewall is a possible culprit, although even disabling it hasn't seemed to work for me yet.