-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
The current version may still have problems when multiple interfaces are present #43
Comments
There is an additional issue I just came accross when using multiple nics. You can't bind to 0.0.0.0:5353 and expect to receive the multicast traffic coming on the second nic. You need the call to bind to listen to 224.0.0.251.5353 instead. In my case (a quick and dirty test), I use the following:
Otherwise, I was never receiving the packets in the process. |
Looking at #38 it addresses this by keeping the bind call to just the port allways, regardless of number of interfaces specificied. I think this is nicer, especially since it will also catch unicast queries / replies. |
You may run into problems if you try this on a Windows operating system. I was using the method of binding to the multicast DNS IP address and it worked fine under linux but I ran into problems when using the code under Windows. I don't know if it is a Windows specific issue or if there was some conflict with some other application. I should probably take pull request #42 from @panta and update the code for another PR, but for now I've reworked the code from @mafintosh into mdns-server (I know, shameless plug ;) and I've focused my efforts there for now. |
Indeed regarding the multicast bind. It would also block you from receving unicast queries which the protocol supports. I've gone back to basically removing the interface's ip on the call to "bind" and be done with it. I will take a look at your code as well. Not sure what the difference is. |
Yeah, binding to group ip and port, which is recommended in a StackOverflow discussion, only works on non-Windows systems (linux, macos) for me as well. |
I have created my own fork that summarizes and incorporate all info here and on other branches. I am not sure if I should send a pull request since I also changed the coding style (to ES6), removed the |
Just pushed a new minor that should have much better support for this. Feedback welcome |
If this is still not fixed, please re-open |
There are cases in which a host has multiple interfaces (e.g., the host is a host for virtual machines, etc.). However the
bind
andaddMembership
API has different semantics according the to manual:bind
:For UDP sockets, ... If address is not specified, the operating system will attempt to listen on all addresses. Once binding is complete, a 'listening' event is emitted and the optional callback function is called.
addMembership
:... If the multicastInterface argument is not specified, the operating system will choose one interface and will add membership to it. To add membership to every available interface, call addMembership multiple times, once per interface.
Therefore, due to this semantics mismatch, maybe the current
listening
handler:Should be changed into something like:
where
opts.interfaces
can be used to specify a list of interfaces that the current instance wish to listen to and keep theopts.interface
null (or undefined) when multiple interfaces are to be handled ?(see also #41)
My suggestion haven't been tested in an active project, but it will be in a few days ...
The text was updated successfully, but these errors were encountered: