-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Regular hostByName via mDNS failure with Ticker #6650
Comments
Most strangely, I tried setting station mode with a short delay immediately following it and the cadence changed consistently from pass - fail - pass - fail to pass - pass - fail - pass - pass - fail. The lines added immediately after connecting to wifi were:
At this point, my brain exploded and I ran out of guesses. Sorry about the close/open - I hit the wrong button. |
@lbussy AFAICT, what you're trying to do isn't supposed to work at all, i. e. WiFi.hostByNsme() isn't supposed to resolve the ".local" domain and should just fail. I have no idea why it works sometimes for you. |
@devyte I'm at a loss then - close this I suppose. Can you tell me before I go away and nurse my wounds how I am supposed to do an mDNS lookup by name properly? The examples I see in the libs all seem to look for a service. The host I am seeking may not be advertizing a service. Searching the web, well, all sorts of answers and there's even a published lib for it - which does not work and causes a WDT reset. |
Technically, it should work. When builtin resolver sees .local, it will send DNS request to the mDNS multicast address (also see #6613 and the example
So it will edit: (I think I was mistaking delay with yield here) Have you tried using Ticker::attach_scheduled() instead or calling in loop checking millis() / PolledTimeout? |
Thank you @mcspr for detailing that. Now I know I'm not crazy at least. I have no doubt that my issue may lie in/with Ticker(). I'll try Ticker::attach_scheduled() and see how that impacts my sketch. I'd never considered it. Incidentally, I ended up using a local cache to get by the sporadic host lookup issues. At least I can get past this for now and will revisit it later. |
@mcspr you're right. The lwip mdns is rather broken, so that internal mdns resolver was supposed to be disabled. |
Tried that as a straight replacement and it seemed to fail to fire. The way I understand it, this would change it to an interrupt-driven event? Anyway, I don't have physical access to my test rig right now and having blown up the connection somehow I need to wait till later to try to debug. |
Not to go off topic, but are there any specific problems there? It is not lwip-mdns lib though, just a basic dns resolver sending request to 224.0.0.251:5353 instead of configured dns server and then receiving dns response back.
It's a quite short alias for attach + schedule_function: Arduino/libraries/Ticker/Ticker.h Line 40 in 1e17ddd
Where schedule_function will run the function some time after loop() function finishes: Arduino/cores/esp8266/core_esp8266_main.cpp Lines 160 to 164 in 1e17ddd
|
I did look at that and as you say it seems simple enough. However it it not seem to ever fire the scheduled task:
You don't mean "finished" as in returned from loop() do you? I may not be following there. |
@lbussy Scheduled functions fire in between calls to loop. You're not letting that happen, because you're holding the loop with a busy loop that calls yield. |
Aha! Okay, that makes much more sense now - thank you. Tested with the TickerBasic.ino moved to Ticker::attach_scheduled() and it operated as it should so I'll play around with how I am doing my work and see if it can provide some relief. Finding a given PR in this project is daunting, but there's reasonable ways to get around it for now so I'll let it come out in the wash. |
scheduled functions are not called from (recurrent scheduled functions (that must not call |
Basic Infos
Platform
Settings in IDE
Problem Description
This is a repost of #6639 with updated verbiage and MCVE.
hostByName resolution fails regularly with -5 when called with Ticker using mDNS. When Ticker is attached with a 5 second interval, it fails every other time. When called with a 2 second interval, it fails every 5th time.
When using DNS/Internet addresses, I cannot reproduce the issue.
MCVE Sketch
Debug Messages
The cadence demonstrated here continues forever.
The text was updated successfully, but these errors were encountered: