bonjour icon indicating copy to clipboard operation
bonjour copied to clipboard

Discovery not working - sometimes (W7)

Open 131 opened this issue 9 years ago • 2 comments

I'm playing with a very simple bonjour.js

// browse for all http services
bonjour.find({ type: 'http' }, function (service) {
  console.log('Found service %s on %s:%d', service.name, service.referer.address, service.port)
})

Most of the time, all my http services are properly found (dns-sd -B confirm) I stop stop Apple bonjour service net stop "Bonjour Service", node bonjour.js still works , dns-sd is down. I re-start Apple bonjour service net start "Bonjour Service", dns-sd -B works, node bonjour.js do NOT find anything anymore, until i reboot my computer...

Tested with node 4.4 & 5.1 (& nw) => same results.

Is there any "lost udp datagram" somewhere you think i should look for ? Any idea on how to fix this ?

Thank you for your help !

131 avatar Jun 17 '16 10:06 131

Having what seems to be the same issue.

matthewtmoran avatar Jul 18 '17 12:07 matthewtmoran

The problem is to do with the lack of caching in the implementation. The code relies on each packet containing all the records required to trigger service up/down events. However, real systems (e.g. restarting apache on an avahi-daemon-based host) sometimes send packets with partial information, expecting the TTLs from previous packets to be honoured, so that the logical content of all packets is combined to yield the active set of services.

To fix this bug, bonjour will have to sprout a TTL-honouring cache, and a means of combining raw RRs from that cache into service up/down events. (The current implementation only considers the RRs in a single packet at a time.) Cribbing from avahi might be a reasonable thing to do -- avahi-browse -aprk quite reliably does the right thing.

tonyg avatar Dec 11 '18 21:12 tonyg