Skip to content
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

Update AsyncWebServer and enable response queue #4516

Merged
merged 7 commits into from
Jan 26, 2025

Conversation

willmmiles
Copy link
Collaborator

Update to the current versions of AsyncWebServer and AsyncTCP, and enable the new AsyncWebServer response queuing feature. This allows for deferring responses when the JSON buffer is locked, or if the system is low on memory. It also adds an "emergency" 503 response if the system does not have enough memory to serve a request. The updated AsyncTCP includes a redesign of the event queue which attempts to ensure that connections won't be leaked if the system runs out of memory.

I've been testing this for about a year now. I think it's as ready as it's going to get.

Replaces #4119

Includes update to use matching newer AsyncTCP on ESP32
Enable the new concurrent request and queue size limit features
of AsyncWebServer.  This should improve the handling of burst
traffic or many clients, and significantly reduce the likelihood
of OOM crashes due to HTTP requests.
This can be helpful for debugging web handler related issues.
Use the web server's queuing mechanism to call us back later.
No locking contention, but a much larger target
platformio.ini Outdated
@@ -259,7 +259,7 @@ large_partitions = tools/WLED_ESP32_8MB.csv
extreme_partitions = tools/WLED_ESP32_16MB_9MB_FS.csv
lib_deps =
https://github.com/lorol/LITTLEFS.git
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
willmmiles/AsyncTCP @ 1.3.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor style thing - can you please define this in a common section then reference rather than repeated definition

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that comment wasn't clear enough. I didn't mean a mass restructure of all common aspects of the envs, just you lib definition

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid I don't understand, then. This particular lib_dep, and the associated build_flag (-D CONFIG_ASYNC_TCP_USE_WDT=0) are examples of flags common to all ESP32 platforms; however the current platformio.ini treats each hardware platform as independent. It doesn't make sense to me to make a new common section for some arbitrary subset of the "all ESP32" options, but leave others behind?

  • It would be wrong to put this specification in the "[common]" section as this library is platform specific
  • It would be wrong to put this in the "[esp32]" section, as that section is a machine specification for the single group of no-suffix chips (ie. it is like "[esp32s2]"); evidenced by the platform specification in that section that applies only to those specific chips, and other contents in the build_flags
  • It would be wrong to create an "[esp32_common]" section for just this one library and its build_flags, and ignore the other common build flags

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Let's hang fire on and cleanup refactoring for now, leaving your repeated definition and then have a dedicated PR to do the cleanup of the envs, rather than mixing the desired style with this PR while leaving existing issues unresolved or blurring the scope of this PR, which then causes other issues

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this instance it's ok to just do a reset and force push to remove the final commit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netmindz netmindz added this to the 0.16.0 candidate milestone Jan 24, 2025
@netmindz
Copy link
Collaborator

Good news, let's get this into main and get others using it too.

We can then decide if we backport to 0.15.x if it's bringing stability improvements

@willmmiles willmmiles requested a review from netmindz January 24, 2025 19:53
Copy link
Collaborator

@netmindz netmindz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only refactor the lib dep

@netmindz netmindz merged commit 61b9947 into Aircoookie:main Jan 26, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants