-
Notifications
You must be signed in to change notification settings - Fork 4
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
node-mdns is broken #17
Comments
Tested https://github.com/mdns-js/node-mdns-js and it works. Good alternative until there is service discovery service. |
That last one applies to your problem I think. The warnings are just there because node-mdns uses the Bonjour compatiblity library on Avahi (it does this because it already uses Bonjour for Mac OSX). It does discover machines, but it doesn't resolve their domain names correctly on some systems without the fix (agnat/node_mdns#149). The fix was found by folks trying to make node-mdns work on Raspberry Pi. I ran into the problem when running inside Docker. I think it's triggered in these environments because they only support ipv4, whereas node-mdns tries to resolve addresses on both ipv4 and ipv6. As for
So, it's still a good option to investigate. Mainly I'd like to use node-mdns-js, because compilation on Windows is really annoying and it doesn't need any existing mdns daemon (no Bonjour on Windows). |
Oh, this is also related to #11. |
Is this the reason why I get "Machines:" box empty with BBM machinkeit running on same subnet? |
node-mdns is in my opinion not worth fixing unless you want to completely rewrite it. Either we go with a discovery service or one has to build a node module based on jdns (https://github.com/psi-im/jdns) which is a proper cross-platform implementation. Letting the OS resolve the hostname does not work on Windows since it does not support .local hostnames. So hostname lookup using mDNS needs to be done in the service itself. |
@zhivko If you do not get errors like mentioned above, it's is a different issue. If you're on Linux, you can check what services Avahi has discovered using @Strahlex As for node_mdns, can you explain why it is not worth fixing? Hmm, I was under the impression Bonjour was needed on Windows, which would do the resolving. I am not that familiar with the mdns protocol itself, but it seems we need discovery (passively listening for advertisements of mdns) and resolving/lookup (actively asking for addresses). Is that correct? |
node-mdns is based on the Apple mDNSResolver library which is not a very good mDNS implementation, especially considering that node-machinetalk will mostly run on Linux hosts. Unless you fix the dependency on mDNSResolver you will not fix node-mdns. One thing people always confuse is mDNS, Zeroconf and Bonjour. mDNS is multicast DNS -> meaning DNS lookups based on multicast, how well multicast works strongly depends on your networking hardware, unfortunately a weak point that one should blame all these ISPs installing cheap routers in home network for. mDNS is not purely passive, a good implementation queries the multicast group when started, newcomers to a multicast group announce themselves, queries are refreshed after a certain timeout (depending on networking hardware) mDNS does not resolve any services it is just DNS over multicast, queries retourn pointers (A, AAA, SRV, PTR, ...) DNS-SD is service discovery over DNS, meaning it works over multicast DNS and unicast DNS Zeroconf is mDNS + DNS-SD -> node-mdns is actually a Zeroconf implementation Bonjour is Apples name for Zeroconf A DNS-SD service discovery consists of multiple DNS queries. I think 3 in total. Address resolution is part of it BUT it resolves the address of the host doing the announcement not the host announced. Therefore, one needs to do another mDNS query resolving the DNS-SD also works over unicast. Avahi supports that type of lookup, this a very good fall back vehicle when you are in network with bad or no multicast support (e.g. RNDIS USB). Most implementations do not support that. This is huge advantage of JDNS or if you would create your own DNS-SD implementation (node-multicast-dns does only the multicast part, unicast lookup should be supported by node). |
Ah! That explanation makes things click. Ok, so we need to avoid mDNSResolver (dns_sd.h). I get your initial idea now. A service that supports all of it, but is still language independent. Bindings still need to be written though. I like the idea, but I don't like running a separate non-standard service in the background. How about using the dbus API for Avahi? It does basically the same, but it is a standard service that is available on many systems. There are good bindings for dbus for most languages already. Python already has the Avahi API implemented on top of dbus, the same could be done for Node. So, these are the options and their pro/cons:
|
@bobvanderlinden the result of avahi-browse-a:
But machine box still empty. I guess It should show machinekit service on beaglebone? When staring machinekit-example I get few errors like:
|
@zhivko There is no Machinekit service shown at all. Have you started a Machinekit instance? @bobvanderlinden If node will only run on Linux (which is likely, since it is the server) then the dbus avahi approach makes sense. There is actually an implementation for node based on dbus: https://github.com/izaakschroeder/node-avahi It is outdated an uses some weird 3rd party dbus interface, but I have also found |
@Strahlex machinekit is running on beaglebone. I have axis present and can jog steppers. |
@bobvanderlinden Service discovery in Python uses exactly the same dbus interface. (https://github.com/strahlex/pymachinetalk/blob/master/pymachinetalk/dns_sd.py) However, the pythob-dbus implementation is not very good (uses gobject event loop). I am pretty sure node could handle this a lot better since it is made for multithreading. |
@zhivko If you are running Axis you are not running Machinetalk. You need a (headless) Machinetalk capable configuration to try out node-machinetalk. |
OK I think I have enabled remote in linuxcnc.ini, avahi shows now:
But browsing to http://localhost:3000/ still show empty machines box. |
Hmm, strange. Does the output of node tell you anything? |
node-mdns uses the mDNSResponder interface which is pretty much broken on Linux. It looks like no proper mDNS implementation (at least not discovery-wise) for nodejs exists at the moment. I suggest making service discovery modular so that it can be used from nodejs and others (e.g. using avahi oder jdns). Idea: create a service discovery service (e.g. with the Python avahi bindings) and bind it to a well known ipc socket -> all machinetalk components can use it independent on the language
The text was updated successfully, but these errors were encountered: