Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multiple Advertisements without network #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tkurki
Copy link

@tkurki tkurki commented Sep 1, 2019

Dnssd fails with

events.js:186
      throw er; // Unhandled 'error' event
      ^

Error: send ENETUNREACH 224.0.0.251:5353
    at SendWrap.afterSend [as oncomplete] (dgram.js:678:11)
Emitted 'error' event on NetworkInterface instance at:
    at NetworkInterface._onError (/tmp/lib/NetworkInterface.js:438:8)
    at SendWrap.callback (/tmp/lib/NetworkInterface.js:393:50)
    at SendWrap.afterSend [as oncomplete] (dgram.js:683:8) {
  errno: 'ENETUNREACH',
  code: 'ENETUNREACH',
  syscall: 'send',
  address: '224.0.0.251',
  port: 5353
}

if you create multiple Advertisements on a host with no network available. As far I can tell the reason for this is that the Advertisements share one NetworkInterface, that is shut down when the first Advertisement fails, but there are outstanding that nobody is listening to.

Just adding error handlers to Advertisements do not catch the secondary errors, so somebody using dnssd has no way to guard against this condition.

The PR includes a simple way to demonstrate this with Docker.

I am not familiar enough with dnssd if the fix I included is the way to go. If you have a better way forward please let me know.

My motivation for using dnssd is to be able to work without mdns's native dependencies and possible separate Avahi installation. The original problem that I am solving is that this fails on setups with no internet connection, eg. no gateway and 224.0.0.251:5353 throws ENETUNREACH - the docker incantation is just an easier way to reproduce the issue.

Add a simple example that fails when run without a network,
for example with Docker. See the file for an example on how
to execute it.
tkurki added a commit to SignalK/signalk-server that referenced this pull request Sep 1, 2019
Handle errors from dsnsd Advertisements and use a version of
dnssd that does not throw out of band errors. Once
or if DeMille/dnssd.js#13 or something
equivalent makes it to npm we should go back to the
upstream version of dnssd.
tkurki added a commit to SignalK/signalk-server that referenced this pull request Sep 1, 2019
Handle errors from dsnsd Advertisements and use a version of
dnssd that does not throw out of band errors. Once
or if DeMille/dnssd.js#13 or something
equivalent makes it to npm we should go back to the
upstream version of dnssd.
tkurki added a commit to SignalK/signalk-server that referenced this pull request Sep 8, 2019
Handle errors from dsnsd Advertisements and use a version of
dnssd that does not throw out of band errors. Once
or if DeMille/dnssd.js#13 or something
equivalent makes it to npm we should go back to the
upstream version of dnssd.
Ignore errors from NetworkInterface, when there are no listeners.
Without this multiple Advertisements on a host with no network fails
when NetworkInterface emits errors after the first emitted error
has already stopped the interface, but there are pending
errors from the socket.
@tkurki tkurki force-pushed the advertisements-without-network branch from 44b1347 to 819538b Compare October 26, 2019 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant