watson / bonjour

A Bonjour/Zeroconf protocol implementation in JavaScript
MIT License
627 stars 146 forks source link

Goodbye message wasn't sent #55

Open SerebryanskiySergei opened 5 years ago

SerebryanskiySergei commented 5 years ago

Hi All! I'm trying to stop service using: this.logger.info('Stopping P2P mDNS annoucement...'); this.service.stop(); this.bonjour.unpublishAll(); this.bonjour.destroy();

But unfortinately my browser still have a service in the service's list after that call, so looks like it doesn't receive a goodbye message.

Am I doing something wrong?

MeirionHughes commented 5 years ago

Same here. Neither service stop nor unpublishAll seems to trigger the "down" event on the Browser side.

MichaelGoberling commented 4 years ago

I think you need to call destroy() in the unpublishAll() callback.

bonjour.unpublishAll(() => {
    bonjour.destroy()
});

After some testing, I found that if you call destroy() before unpublishAll() actually finishes, a goodbye message won't be sent.