Annex-Engineering/klipper_estimator

RFE: Support hostname DNS resolution

wannabecoffeenerd opened this issue · 1 comments

Currently, specifying the moonraker url as a hostname does not seem to work, but specifying the IP address does.

$ ./klipper_estimator_linux --config_moonraker_url http://neptune.local estimate ~/N2_3DBenchy.gcode
Failed to load printer configuration: request failed: error sending request for url (http://neptune.local/printer/objects/query?configfile=settings): error trying to connect: dns error: failed to lookup address information: Name does not resolve

However, going to that address in the browser does bring up the settings. Specifying the IP address works:

./klipper_estimator_linux --config_moonraker_url http://192.168.1.195 estimate ~/N2_3DBenchy.gcode
Sequences:
 Run 0:
  Total moves:                 103699
  Total distance:              148578.751mm
  Total extrude distance:      3827.612mm
  Minimal time:                41m35.739s (2495.739s)
  ...

It would be a really nice usability feature to support hostname resolution and not necessitate a static IP

Hi @wannabecoffeenerd !

The URL does support DNS resolving, but to look up .local addresses, the system you run klipper_estimator from must support mDNS lookups via standard gethostsbyname. This is usually configured in /etc/nsswitch.conf or via systemd-resolved. E.g. in my case I have in /etc/nsswitch.conf:

...
hosts: files mymachines myhostname mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns
...

This attempts mDNS .local lookups for the system resolver.

I've verified that this also works with klipper_estimator.

It is possible that your browser allows this because it doesn't use the system DNS resolver. I don't use mDNS myself day to day, so I'm not really sure on the implementation status in various software. Sorry! :-(

Best regards,
Lasse