-
Notifications
You must be signed in to change notification settings - Fork 7
Bind the receive socket to the catch-all addresses #2
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
Conversation
Windows may have issues with this change. I put together this module to address issues with mDNS on Windows machines with multiple network interfaces... When I attempted to use the catch-all address 0.0.0.0 Windows would select the first interface to listen and as a result would not receive mDNS answers coming back on other interfaces. However, I did setup a test with your changes on a Windows 10 system and it seems to work okay (perhaps Microsoft fixed this?) but I'm still reluctant to merge due to client systems that could potential fail. So, a couple of questions for you... Would it work for you if we added an option that would enable the use of the catch-all 0.0.0.0? This could solve the OSX issue without potentially breaking other implementations. And have you tried using the module on an OSX system with multiple network interfaces? I don't have access to an OSX system to run tests, I can only test Windows and Linux. |
I thought of another solution: Try to bind to a specific IP address, and if that fails due to EADDRINUSE, try again with the catch-all address. Adding an option means the user has to understand what it does, when it should be used and when it shouldn't. The fallback solution means that it just works.
I don't have access to OSX either. |
Fantastic solution, much better than my proposal. Do you have time to code this or would you like me to take a stab at it? When I'm in the office I'll check to see if we have a Mac anywhere. As an alternative, perhaps we can work with Boimb on OSX testing assuming he is game for more work on the same issue. :) |
I'll see if I can give it a try tomorrow - but no promises. |
How I can I help you with this ? [EDIT] As far as I understood, @AlCalzone included his own version of "mdns-server" in the master Branch of "node-tradfri-client". So I pulled this one for test. Here's the result :
Btw, feel free to ask for further tests. |
@Boimb we basically need someone with OSX to test the changes @bnielsen1965 or I will be making soon. Nothing to do yet, but we'll ping you when there's something to test if you're up to. |
EDIT: I have a Mac now, the hotfix branch fails, but I may have a fix... @Boimb https://github.com/bnielsen1965/mdns-server/tree/hotfix It will retry the catch-all address if the bind fails on the interface address as suggested by @AlCalzone . |
Okay, lets try this again... @Boimb @AlCalzone |
I'll check tonight |
The hotfix works for me :) Windows 10 |
@AlCalzone do you have a branch including this hotfix on "node-tradfri-client" that I can can pull ? |
@Boimb If you want to do a quick and dirty test you could download the index.js file from the hotfix branch and copy it into your node_modules/@alcalzone/mdns-server/ directory. https://github.com/bnielsen1965/mdns-server/blob/hotfix/index.js |
I love when it's dirty ^^ |
Great. let me know when that is published and I‘ll release a new version 😁 |
Merged and published as version 1.0.6 |
@AlCalzone @Boimb Looks like we are in good shape so I'm going to close this. Thanks for helping me improve this module. |
First of all, thanks for this library - it seems to be the only one that allows to detect Tradfri gateways on a variety of networks.
bonjour
andmulticast-dns
both have flaws in this regard.When mDNSResponder is running on OSX, binding the receive socket to a specific IP address will throw
EADDRINUSE
, even ifreuseAddr
is set totrue
, as can be seen from this rather long bug hunt: AlCalzone/node-tradfri-client#101The solution seems to be binding the receive socket to the catch-all addresses
0.0.0.0
(IPv4) and::%<name>
(IPv6) instead.