Skip to content

Resolve mDNS address for MQTT broker #4671

Closed

Description

@schildbach

When connecting to an MQTT broker, please allow putting an mDNS domain into the "broker" field. Currently (on version 0.15.1.beta2) it seems only IP addresses and regular DNS names are supported.

Activity

  1. blazoncek commented on May 1, 2025

    @blazoncek
    Contributor

    MQTT broker is considered a "server" and as such should have a static IP address.
    Adding ability to enter FQDN (or at least hotname) adds to complexity and increases code size.

  2. added
    backburner
    on May 1, 2025
  3. schildbach commented on May 1, 2025

    @schildbach
    Author

    Just for reference, both mDNS and DNS can point to static IP addresses as well.

    DNS is already supported in the field.

    Tasmota can resolve both mDNS and DNS as well.

  4. Jason2866 commented on May 1, 2025

    @Jason2866
    Contributor

    Agree that servers have in general a static IP. Nevertheless even in my LAN i don't put an IP address in any config. My mqtt broker has mqtt.lan as DNS name for example. Don't agree that it puts a lot of code to resolve the DNS name in an IP address. It makes it a lot easier to maintain stuff. If the IP address changes of a server it is a lot of "fun" to change all the addresses in all devices. Imho it is a no go not to support DNS name resolution.
    A lot of flash space can be saved to drop support for the crappy mDNS which brings as "benefit" a lot of issues when used with an esp8266 / esp32.
    Tasmota does not support mDNS

  5. blazoncek commented on May 1, 2025

    @blazoncek
    Contributor

    I did not say it won't or shouldn't be implemented. 😄

  6. schildbach commented on May 1, 2025

    @schildbach
    Author

    Tasmota does not support mDNS

    I think it does: arendst/Tasmota#6866 (comment)

  7. Jason2866 commented on May 1, 2025

    @Jason2866
    Contributor

    @schildbach I am a member of Tasmota dev core crew. The post ist really old you linked. I convinced Theo to remove mDNS support in all precompiled binaries one or two years later ;-)

  8. blazoncek commented on May 2, 2025

    @blazoncek
    Contributor

    As an Apple user I have yet to find an issue with mDNS. My experience is that incorrectly set up networks may exhibit issues with mDNS. And once those are resolved it is up to devices to support it.

    That being said, I fully understand the benefits of DNS (or mDNS) resolution. Unfortunately the issue #4586 will add headeaches if only DNS is used, and I have no idea on how to resolve that.

    As for WLED to support DNS/mDNS resolution, plenty of UI fields would need to be updated adding code (JS/HTML) as well as backend validation and DNS resolution. If someone finds the time and will to comb through all of it I will be more than happy to help.

  9. blazoncek commented on Jul 8, 2025

    @blazoncek
    Contributor

    Anyone interested may want to try adding this in mqtt.cpp to initMqtt() function:

    ...
        #ifdef ARDUINO_ARCH_ESP32
        if (strlen(cmDNS) > 0 && strchr(mqttServer, '.') == nullptr) { // if mDNS is enabled and server does not have domain
          mqttIP = MDNS.queryHost(mqttServer);
          if (mqttIP != IPAddress()) // if MDNS resolved the hostname
            mqtt->setServer(mqttIP, mqttPort);
          else
            mqtt->setServer(mqttServer, mqttPort);
        } else
        #endif
    ...

    in the elseportion of if (mqttIP.fromString(mqttServer).

    And then, please, report back.

  10. added a commit that references this issue on Jul 12, 2025
    2152282
  11. removed
    backburner
    on Jul 12, 2025
  12. added a commit that references this issue on Jul 12, 2025
    79b3bc2
  13. blazoncek commented on Jul 14, 2025

    @blazoncek
    Contributor

    @schildbach please test #4769 and report back (in PR).

  14. added
    waiting for feedback
    on Jul 14, 2025
  15. schildbach commented on Jul 14, 2025

    @schildbach
    Author

    @schildbach please test #4769 and report back (in PR).

    Is there any way to build WLED in a container, like within Docker or Podman? Or do you have WLED images for pull requests somewhere? I don't have the dev environment available, in particular no Visual Studio.

  16. blazoncek commented on Jul 14, 2025

    @blazoncek
    Contributor

    If you don't need customised binary, please use Github's CI builds. You can find them in PR.
    Otherwise follow instructions in KB. AFAIK VSC is free but is not needed. You do need PlatformIO, though.

  17. added a commit that references this issue on Aug 8, 2025
    8443ecd
  18. added a commit that references this issue on Aug 18, 2026
    3e69f20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementwaiting for feedback

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions