Closed raffaeler closed 5 months ago
Add bool shouldReboot = false;
to global scope and then in the handler set it to true instead of directly calling the reboot();
. Then in your main loop check if shouldReboot
is true and call the reboot();
there. Depending on your platform you may need to add some delay before running the reboot to make sure the response has actually been sent to the client.
This is exactly the current workaround :-) I was wondering what background tasks need to be executed and if there is any way to trigger them instead (aesthetic reason for my code).
Thanks!
If you are closing the connection already just adding the delay may do the trick. For example the ESP platforms are multithreaded and the actual data sending happens async. if you reboot immediately the response may not have been actually sent.
I suspected and the last call to rebooting has a delay inside, but I believe that threads get stopped and thus also the web activity.
With most platforms the delay should call yield internally and let all the os run whatever is needed in the meanwhile. You may try to flush the response before calling reboot. But all this depends how the tcp client is implemented in the used platform. Doing it in the main loop is the most safe way to do this.
Got it, thank you!
Hi, I am trying to send a complete response and close it before a reboot. Unfortunately, the client never see the response coming. The ESP32 close the connection before flushing the full response out.
What I tried:
In a similar code using the WebServer class, I never had this kind of issues.
What am I missing? TIA