-
Notifications
You must be signed in to change notification settings - Fork 13.3k
mDNS in NodeMCU #8912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Latency always that high?
Any difference when dealing with DNS client directly? > Resolve-DnsName -llmnronly ESP-4A2914.local
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
ESP-4A2914.local A 120 Answer 10.10.10.137 (check out afaik we are dealing with multicast replies; looking at ping, there is a single query. PS cmdlet sends out more than one, thus also receiving more than one reply (with consideration that it might miss some requests in the process) |
@mcspr Thanks for the response! I think I found a solution, so I am detailing it here.
I am afraid so... I placed the device close to the router and ran the ping command again. This is the result:
Is there anything that can be done to improve this?
Without any changes to the code, not really. It couldn't be found: > Resolve-DnsName -llmnronly esp8266.local
Resolve-DnsName : esp8266.local : This operation returned because the timeout period expired
At line:1 char:1
+ Resolve-DnsName -llmnronly esp8266.local
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationTimeout: (esp8266.local:String) [Resolve-DnsName], Win32Exception
+ FullyQualifiedErrorId : ERROR_TIMEOUT,Microsoft.DnsClient.Commands.ResolveDnsName What was bothering me is that the MDNS worked for a short while before stopping completely, so I decided to read the source code and see if there was anything there that could help me. That's how I found the bool MDNSResponder::announce(void) which seemed worth try using -- maybe MDNS was announcing just once and that is why it worked only once as well, who knows? Then I created a quick-and-dirty workaround to test this hypothesis. First, I added this to the beginning of the file: // counter used for delaying the call to MDNS.announce()
long int advertiseCounter = 0; and then I changed the void loop(void) {
server.handleClient();
MDNS.update();
// call MDNS.announce() periodically when the counter exceeds the threshold, then resets the counter.
if (advertiseCounter++ > 100000)
{
MDNS.announce();
advertiseCounter = 0;
}
} And now I can find the device successfully on Windows =) > Resolve-DnsName -llmnronly esp8266.local
Name Type TTL Section IPAddress
---- ---- --- ------- ---------
esp8266.local A 120 Answer 192.168.50.43
Name : 43.50.168.192.in-addr.arpa
QueryType : PTR
TTL : 120
Section : Answer
NameHost : esp8266.local The browser can also find it, so I think this issue is at least partially solved... And the reason for the "partial" is that although it works in Windows, it doesn't work at all with Android... On Windows it works whether I use |
https://stackoverflow.com/questions/30449988/how-to-enable-mdns-support-in-android-browser-address-bar |
It's not a MDNS error; it fails even when I use the IP itself. I will try with a different phone and see what happens. |
Uh oh!
There was an error while loading. Please reload this page.
Basic Infos
Platform
Settings in IDE
Problem Description
None of the mDNS samples work for me. I can connect through the IP address, but I am not able to find the device using mDNS.
The sample that works the "best" so far is the HelloServer. After it connects and prints
I start pinging esp8266.local and it works once, but then it stops working:
I didn't do any changes to the sample code (other than the network data) and I couldn't find anyone with a solution to this problem either.
Any ideas of what could be preventing MDNS from working after the first time? I am not using OTA and I am erasing all flash contents.
I am pasting the sample code for completion:
MCVE Sketch
The text was updated successfully, but these errors were encountered: