HaddingtonDynamics / Dexter

GNU General Public License v3.0
363 stars 84 forks source link

Enabling mDNS "bonjour" hostname.local support on Dexter #83

Open JamesNewton opened 4 years ago

JamesNewton commented 4 years ago

mDNS is a service that allows local devices to put their names into the local network for resolution instead of ip address, without requiring standard DNS records. https://en.wikipedia.org/wiki/Multicast_DNS It is used by the Apple Bonjour service and is support on Linux via Avahi and is not supported in Windows 10. The advantage is that each Dexter could be found on the local network by entering it's hostname, followed by ".local" into the browser or other network address.

All that is required is to set the robots name in the /etc/hostname file. For example, on my robot, that file contains a single line: DEX-197121 then, for example, I can go to: http://DEX-197121.local and the onboard node server well respond with the web page. Or I can ping 'DEX-197121.local'

If we automatically set this from Dexters serial number, users could just glance at the serial number plate and not have to find the IP address. It would be easy to add this to the current functionality in RunDexRun which sets the mac address from the serial number to avoid mac address crashes on the network (all of the microZed boards come with the same mac address).

Of course, that depends on the Defaults.make_ins file having the serial number in it in the format that RunDexRun expects: DEX-####### where the '#'s are replaced with the serial number. Including different letters at the start (other than "DEX") increases the number of possible combinations past what is possible in the mac address, so that must always start with "DEX-"

Another option is to manually edit that file when a new robot is commissioned as part of the calibration instructions. In that case, any valid domain name is possible. E.g. you could have "HDI-123456". Or you could even have a customer supplied nickname like "fred" and reach it at fred.local

It would also be possible to have some sort of configuration script via command line, DDE, or the web browser which collects information and then sets this (and possibly other things) as a result.

(Note: This issue is just to document work that was done in January with Phil Joy which was not implemented or documented previously)

JamesNewton commented 4 years ago

I've done a little testing on this mDNS now that I'm switching to Ubuntu 16.04 as my work OS. Previously, the version of Windows I've used doesn't support mDNS so it not working there is expected. What I've found is that I can ping dex-197121.local and it resolves to the correct IP instantly. But if I try to browse to http://dex-197121.local the browser (Chrome or Firefox) hangs waiting for the page to load. By watching the web server logs in the robot, I can see that the request did reach it, and the page was supposedly written back, but the browser doesn't seem to get it. The same browser, same window, works perfectly when given the ip address instead. I've searched and found other people reporting multiple other problems, but not this exact thing. This one is close (different version of Ubuntu and using Chromium, not Chrome) https://superuser.com/questions/1354448/chromium-on-ubuntu-doesnt-resolve-local-address-though-other-applications-do

Someone with a mac, and someone with Windows 10 should really try this and see if it works.

JamesNewton commented 4 years ago

"Someone with a mac, and someone with Windows 10 should really try this and see if it works."