Skip to content

Commit 24f2306

Browse files
committed
Strip .local from mDNS resolution
1 parent 79b3bc2 commit 24f2306

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

wled00/mqtt.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ bool initMqtt()
214214
mqtt->setServer(mqttIP, mqttPort);
215215
} else {
216216
#ifdef ARDUINO_ARCH_ESP32
217-
if (strlen(cmDNS) > 0 && strchr(mqttServer, '.') == nullptr) { // if mDNS is enabled and server does not have domain
218-
mqttIP = MDNS.queryHost(mqttServer);
217+
String mqttMDNS = mqttServer;
218+
mqttMDNS.replace(F(".local"), ""); // remove .local if present
219+
if (strlen(cmDNS) > 0 && mqttMDNS.length() > 0 && mqttMDNS.indexOf('.') < 0) { // if mDNS is enabled and server does not have domain
220+
mqttIP = MDNS.queryHost(mqttMDNS.c_str());
219221
if (mqttIP != IPAddress()) // if MDNS resolved the hostname
220222
mqtt->setServer(mqttIP, mqttPort);
221223
else

0 commit comments

Comments
 (0)