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

Does not work when options.interface is specified #53

Open
moky80 opened this issue Apr 6, 2018 · 6 comments
Open

Does not work when options.interface is specified #53

moky80 opened this issue Apr 6, 2018 · 6 comments

Comments

@moky80
Copy link

moky80 commented Apr 6, 2018

When options.interface is specified:
require("multicast-dns")({interface:"192.168.1.1"})
it didn't work (no error, just no services found) while in the very same system omitting the options worked. The system actually has only one interface 192.168.1.1.

@nriley
Copy link

nriley commented Jul 5, 2018

I ran into something similar in a situation where I did need to use options.interface. options.interface is used in two places — I am not sure it needs to be used in both.

It is used not only to override the default interface (automatic selection of default interface does not do great in complex network environments — at least in my case it generally picks the wrong interface) but also to bind. If I do specify an interface I get EADDRINUSE, I guess because I also have mDNSResponder running. I ended up just removing the reference to opts.interface from bind and it seems to work just fine — dns-sd shows me that multicast-dns has registered on the correct interface and bind works just as it did if I hadn't specified options.interface.

The change I made was specifically to comment out opts.interface here:

    socket.bind(port, undefined /* opts.interface */, function () {

@RangerMauve
Copy link
Contributor

I just ran into this issue and @nriley 's solution resolved it.

@mafintosh Would you be open to a PR that adds a new localAddress option which will be used in .bind() instead of opts.interface? This would be a major version change.

@pascalStm
Copy link

pascalStm commented Mar 28, 2019

I also have a problem that, if I parameter interface with my ip address to select the right interface, I receive multicast udp packets with this address, I must remove "opts.interface" from the bind command to receive all multicast udp packets of all my clients

by putting "ip" instead of "opts.interface" it works for the multicast

@pipex
Copy link

pipex commented Jun 3, 2020

If anyone is still wondering about this after one year like me :p

It seems that the latest version of the package adds a bind to options that is used as address in the socket.bind() call. Setting it to 0.0.0.0 seems to fix the problem.

@ke4nec
Copy link

ke4nec commented Mar 19, 2021

If anyone is still wondering about this after one year like me :p

It seems that the latest version of the package adds a bind to options that is used as address in the socket.bind() call. Setting it to 0.0.0.0 seems to fix the problem.

Thanks!
require("multicast-dns")({bind: "0.0.0.0", interface:"192.168.1.1"});

@otaviojacobi
Copy link

otaviojacobi commented Jul 16, 2024

A complement to this, 0.0.0.0 might not be the most secure interface to bind to (as it will accept incoming connection from any address). An alternative, that seems to work file for me is binding to the mDNS default address 224.0.0.251

edit: It does not seem to work on mac

otaviojacobi added a commit to balena-io/balena-cli that referenced this issue Jul 16, 2024
This is an improvement over the scan, join and leave commands removing flakiness when searching over different networks. In short, instead of leaving bonjour to search across all interfaces, we forcebly conduct a search on each interface, this requires mDNS binding any ipv4 interface (0.0.0.0), otherwise it would bind over the interface itself, which is not desired as it causes services to only be able to receive information over that interface, see [mafintosh/multicast-dns#53](mafintosh/multicast-dns#53). This targeted approach enhances the reliability and accuracy of network searches, reducing instances of missed connections or network errors typically caused by flakiness when relying on bonjour's default behavior.

Change-type: patch
otaviojacobi added a commit to balena-io/balena-cli that referenced this issue Jul 16, 2024
This is an improvement over the scan, join and leave commands removing flakiness when searching over different networks. In short, instead of leaving bonjour to search across all interfaces, we forcebly conduct a search on each interface, this requires mDNS binding any ipv4 interface (0.0.0.0), otherwise it would bind over the interface itself, which is not desired as it causes services to only be able to receive information over that interface, see [mafintosh/multicast-dns#53](mafintosh/multicast-dns#53). This targeted approach enhances the reliability and accuracy of network searches, reducing instances of missed connections or network errors typically caused by flakiness when relying on bonjour's default behavior.

Change-type: patch
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

7 participants