-->
Page 1 of 1

ESP8266 Doesn't Respond to mDNS Query "A"

PostPosted: Sun Apr 25, 2021 2:50 pm
by solaria
Not having much luck using mDNS on an ESP8266 (or an ESP32 either). Tried it with PlatformIO, and Arduino IDE (core 2.7.4); using my code or example code (mDNS_Web_Server); always the same result: works fine for 2 minutes after booting, then fails.

Here's what I expect to happen: pinging from a host (Ubuntu) to a .local address (in this case a Raspberry Pi), it send an mDNS "A" request; the response has the IP:

Image

When I try pinging an ESP8266 running the example program it doesn't respond to the mDNS query and the ping fails:

Image

It will however respond to "PTR" queries, so running mdns-scan first will retrieve the _http._tcp.local service and get the IP that way:

Image

...which is good for 2 minutes, then the mDNS record times-out, repeat...

Basically that's what the Arduino IDE does for OTA: every 100 seconds it sends a "PTR _arduino._tcp.local" request to refresh the OTA hosts. Which means that if you have OTA in your sketch and the IDE is running, mDNS will work fine. But two minutes after you shutdown the IDE the mDNS records will time-out, and mDNS will fail.

Also tried this from the "Windows" operating system. Worked fine pinging a Raspberry Pi host, but never got a successful ping to an ESP8266 host. Interestingly, even though the ping failed, the mDNS records were refreshed and pings to the ESP8266 were successful from all other OS hosts.

So, how do you get mDNS to work on the ESP8266/ESP32?




Re: ESP8266 Doesn't Respond to mDNS Query "A"

PostPosted: Sun Apr 25, 2021 11:20 pm
by Pablo2048
Do You have MDNS.update() in Your loop() ?

Re: ESP8266 Doesn't Respond to mDNS Query "A"

PostPosted: Mon Apr 26, 2021 10:30 am
by solaria
Pablo2048 wrote:Do You have MDNS.update() in Your loop() ?


Yes, the results shown are from mDNS_Web_Server.ino, the ESP8266mDNS example. It has MDNS.update(); as the first statement in the loop. Same thing happens when using ArduinoOTA.begin()/ArduinoOTA.handle(). I've also tried it using MDNS and ArduinoOTA together, same result.

It's not that it doesn't work at all... it does respond to "PTR _services._dns-sd._udp.local" and "PTR _http._tcp.local" requests, so name resolution will work after a service scan (for 2 minutes). It just doesn't respond to the "A" requests, which is what gets sent for name resolution when you ping or HTTP GET. Without that it's kind of useless.

Re: ESP8266 Doesn't Respond to mDNS Query "A"

PostPosted: Tue Apr 27, 2021 11:15 pm
by solaria
It was the router.

Did a "Restore Factory Defaults" on the router, re-configured... and everything worked. No problems.

Huh.