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

Advertisements published on first interface only? #3

Open
svogl opened this issue May 27, 2018 · 7 comments
Open

Advertisements published on first interface only? #3

svogl opened this issue May 27, 2018 · 7 comments

Comments

@svogl
Copy link
Contributor

svogl commented May 27, 2018

Hi,
we have an embedded system with a number of interfaces - eth0, wlan0, bat0 - to name a few.
The following code runs

var DNSSD = require("dnssd");

let _dnsdsBrowser = new DNSSD.Browser(DNSSD.tcp('_mqtt'));
let _dnsdsAdvMqtt = new DNSSD.Advertisement(DNSSD.tcp('_funky'), 2883, { name: 'FUNKY' });
let _dnsdsAdvMqttWS = new DNSSD.Advertisement(DNSSD.tcp('_funky-ws'), 3001, { name: 'FUNKY WS' });

_dnsdsAdvMqtt.start();

but the services show up only on the first interface that has been detected (eth0 in our case, where we don't want it ... ) -- not even at localhost.

How can we make sure it is accessible from the other network participants?
Simon

@DeMille
Copy link
Owner

DeMille commented May 28, 2018

Right, I wondered if this might be an issue. It currently binds the socket on 0.0.0.0, so outgoing packets get sent on whatever interface the kernel thinks is needed to reach the destination. In your case it's probably defaulting to eth0.

Do you need the advertisements on all the other interfaces or just one, like, wlan0? There's a new method (setMulticastInterface) that was added to node in 8.4 that can set the interface to use for outgoing packets. If all your systems can communicate through one of the interfaces that's the easier answer. (I'm actually pretty excited about that one, they didn't have it when I was trying to figure out how to deal with this before.)

Otherwise we'll have to create multiple sockets, one for each interface you need to use.

Either way I think I should add an option to specify interfaces somehow.

@svogl
Copy link
Contributor Author

svogl commented May 28, 2018

Oh fine - did not notice the multicastInterface call; that could indeed work out as we've set up a bridge interface on all nodes sharing data.
When we publish services will this use the multicastInterface as well?
thanks

@DeMille
Copy link
Owner

DeMille commented May 29, 2018

Ok great, I'll add an option to use that setMulticastInterface. That's an easy change. It will affect all outgoing packets, so it should affect browsers and advertisements where used. I'm thinking it'll just be an option along the lines of

const ad = new dnssd.Advertisement(dnssd.tcp('thing'), 8000, { interface: 'wlan0' });
// or
const browser = new dnssd.Browser(dnssd.tcp('thing'), { interface: '1.2.3.4' });

I'll let you know when I get that updated!

@DeMille
Copy link
Owner

DeMille commented May 31, 2018

Alrighty, I've added that option & published it to npm. Give it a shot and let me know if that works with your network config

@wasnotrice
Copy link

Hi, I'm running into this issue from the other direction. We've got an app browsing for a service that is advertised by a device connected to local wifi.

  • when running on a machine with one network interface, all is well
  • when on a machine with multiple interfaces, and they are connected to the same network, all is well
  • when on a machine with multiple interfaces connected to different subnets, then we invariably get the wrong interface.

Is it feasible to pass multiple interfaces to the browser and have it coalesce the results? Ideally, we would be able to discover all available services, regardless of network.

@sbender9
Copy link

sbender9 commented Aug 9, 2019

This is an issue for me. I need the advertisement on all the interfaces with the correct ip address. mdns does this correctly,

@wasnotrice
Copy link

@sbender9 @haakonnessjoen I worked around my issue by finding all of the active network interfaces, creating one browser instance for each interface, and coalescing results from all browsers. That works fine 👍

Also see related fix in #16

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

4 participants