-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Migrate callbacks of new mdns responder to functional #5463
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
@hreintke given your great past work in similar areas, could I ask for your help with this? There is no hurry. |
@devyte OK, I will look into this |
@devyte @LaborEtArs I think there is an error in the MDNSProbeResultCallback function. The
is now on :
But it should be on
|
Unfortunately you’re absolutely right. In fact, the mDNS_Clock example has got the same error... |
So both the clock and servicemonitor examples have the same mistake? |
Yes, That is the one. The update for the functional option is very simple. Only the typedefs neeed change. |
@hreintke yes to the PR please! |
@devyte @LaborEtArs I have trouble getting the LEAnMDS working steady, so I decided to compare legacy and lea using the mDNS_Web_Server.ino example. I test by submitting esp8266.local in chrome browser. Is there a chance that this is caused by the LEA implementation itself ? |
@hreintke that sounds like the missing update() call. Are you using the .ino from latest git or beta2? Please make sure the following line is in the loop in your example .ino:
|
I am using latest git where MDNS.update() is in the loop. Checking more, learning of mDNS and debugging it. |
It is indeed the missing MDNS.update(); Although it is in de loop(), the sketch has :
which prevents the update to be executed. Still to check why using a browser it 'hangs' there and using curl it waits in server.available() |
These lines of code are also included in both new examples (1:1 taken from the original mDNS example). Have you tried these examples also? The mentioned code should only be executed, if a client connects via port 80. Why does the browser already opens a connection to his port if it is asking in parallel for the general 'coordinates' of the target via the MDNS call? Might it be a 'Chrome' speciality? The 'cache flush' should be the mDNS response to some call to the mDNS responder of the ESP. The request should be triggered by the caller at about 80% of the TTL of the ESPs IP address record, which is 120s. So your observed 100s seems to be fine, but: The ESP shouldn't advertise these records 'just fur fun'. So who is the caller? Are there other devices around, that might be interested in the ESP? Have you tried to move the HTTP service to another port? Unfortunately, I haven't got a running ESP environment currently, as my system (using Eclipse as well as Arduino) currently doesn't like to successfully build or upload even a simple 'Hello world' sketch.... working on this.... |
Yes, I've seen the same way of working in the other examples. Those are also failing at my site. The mDNS responses are indeed triggered by a caller. Missed that due to a wrong filtering in Wireshark. Workarounds ready for this, I will make an example for the functional callbacks. |
@devyte @LaborEtArs Running Windows & Chrome browser.
In most examples you won't notice as the loop will end and request will be handled when the new HTTP request comes in. But it also results in the loop() only executing once at each HTTP request. I noticed that you also added mDNS to other examples, those can also be affected by this. |
@hreintke then a timeout in those wait loops is a must, and not just in the examples. |
I think best way forward for the mDNS examples is not to use WifiClient but ESP8266Webserver. If you agree I can do the work on these examples,first updating one in a PR and from there discuss this solution. |
If you mean migrate examples that do http manually to use the relevant objects, then please go ahead! |
@LaborEtArs : |
@hreintke: Have a look into ‚LEAmDNS_Priv.h‘, the timeouts for host and service records are defined there. As the timouts are recommended values from the mDNS spec, I have hardcoded them... |
@devyte @LaborEtArs @devyte : Beware, as the Legacy mDNS is using async UDP, it does not require a MDNS.update() in the loop(); LEAmDNS, which is now the default, however does. Meaning : The Legacy ->Lea patch is a breaking change ! |
@hreintke: The mDNSResponder has two response modes. All services, the were supported by the legacy mDNS version (mainly the service response when asked for) should also be supported in passiv/async mode (without the update call in the loop)... |
@LaborEtArs
|
If so, something has got the flu... To be a bit faster, I would propose to continue this discussion inside the gitter 'mDNS lobby' @devyte created: https://gitter.im/esp8266-mdns/Lobby?utm_source=ios&utm_medium=link&utm_campaign=ios-share-link |
Closing via #5653 |
Basic Infos
Platform
Settings in IDE
Problem Description
The new MDNSResponder implementation written by @LaborEtArs allows for setting up some user callbacks. This is currently implemented in the classic C way with specific function signatures. It would be more flexible to allow std::function, lambdas, and general functors.
MCVE Sketch
See new MDNS examples.
The text was updated successfully, but these errors were encountered: