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

Not broadcasting on all interfaces #32

Closed
andosmith opened this issue Sep 2, 2016 · 2 comments
Closed

Not broadcasting on all interfaces #32

andosmith opened this issue Sep 2, 2016 · 2 comments

Comments

@andosmith
Copy link

I think something in the documentation may be incorrect. In creating a new mdns instance this is one of the option choices:

interface: '192.168.0.2' // explicitly specify a network interface. defaults to all

We were finding that we were only seeing it available on one interface. Looking at index.js:

socket.addMembership(ip, opts.interface)

According to documentation on dgram (the socket), addMembership defaults to a single interface (chosen by the operating system), and if multiple interfaces are desired addMembership should be called multiple times, once per interface. What do you think about taking an array of addresses and calling addMembership on each?

@dlancho
Copy link

dlancho commented Sep 6, 2016

Hi,

As far as I know, in addMembership the passed interface is only to restrict what interface you should listen to, but not which to send.

The problem I found is that when sending packets, the system selects one interface based on unknown (to me) rules (it does not select based on routing table, and it changes every couple of minutes).

In order to broadcast in one specific interface, I had to modify the socket binding by including the same opts.interface as it is in the addMembership call.

var bind = thunky(function (cb) {
    if (!port) return cb(null)
    socket.once('error', cb)
    socket.bind(port, opts.interface, function () {
      socket.removeListener('error', cb)
      cb(null)
    })
  })

The restriction then is that I cannot pass an encoded interface idx as an IP, and I have to pass the interface IP.

I am not sure if there is another way of controlling what interface to broadcast to, but it would be nice to know :-)

@mafintosh
Copy link
Owner

I think this is fixed in latest... If not please reopen.

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

No branches or pull requests

3 participants