- Notifications
You must be signed in to change notification settings - Fork50
ESP32Async/ESPAsyncWebServer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Supports: WebSocket, SSE, Authentication, Arduino Json 7, File Upload, Static File serving, URL Rewrite, URL Redirect, etc.
The completeproject documentation is available in the Wiki section.
The library can be downloaded from the releases page athttps://github.com/ESP32Async/ESPAsyncWebServer/releases.
It is also deployed in these registries:
Arduino Library Registry:https://github.com/arduino/library-registry
ESP Component Registryhttps://components.espressif.com/components/esp32async/espasyncwebserver
PlatformIO Registry:https://registry.platformio.org/libraries/esp32async/ESPAsyncWebServer
- Use:
lib_deps=ESP32Async/ESPAsyncWebServer
to point to latest version - Use:
lib_deps=ESP32Async/ESPAsyncWebServer @ ^<x.y.z>
to point to latest version with the same major version - Use:
lib_deps=ESP32Async/ESPAsyncWebServer @ <x.y.z>
to always point to the same version (reproductible build)
- Use:
[env:stable]platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.ziplib_compat_mode = strictlib_ldf_mode = chainlib_deps = ESP32Async/AsyncTCP ESP32Async/ESPAsyncWebServer
[env:stable]platform = espressif8266lib_compat_mode = strictlib_ldf_mode = chainlib_deps = ESP32Async/ESPAsyncTCP ESP32Async/ESPAsyncWebServer
Version 1.9.1 or newer is required.
[env:stable]platform = libretiny @ ^1.9.1lib_ldf_mode = chainlib_deps = ESP32Async/AsyncTCP ESP32Async/ESPAsyncWebServer
AsyncTCPSock
AsyncTCPSock can be used instead of AsyncTCP by excluding AsyncTCP from the library dependencies and adding AsyncTCPSock instead:
lib_compat_mode = strictlib_ldf_mode = chainlib_deps = https://github.com/ESP32Async/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip ESP32Async/ESPAsyncWebServerlib_ignore = AsyncTCP ESP32Async/AsyncTCP
RPAsyncTCP
RPAsyncTCP replaces AsyncTCP to provide support for RP2040(+WiFi) and RP2350(+WiFi) boards. For example - Raspberry Pi Pico W and Raspberry Pi Pico 2W.
lib_compat_mode = strictlib_ldf_mode = chainplatform = https://github.com/maxgerhardt/platform-raspberrypi.gitboard = rpipicowboard_build.core = earlephilhowerlib_deps = ayushsharma82/RPAsyncTCP@^1.3.2 ESP32Async/ESPAsyncWebServerlib_ignore = lwIP_ESPHostbuild_flags = ${env.build_flags} -Wno-missing-field-initializers
Most of the crashes are caused by improper use or configuration of the AsyncTCP library used for the project.Here are some recommendations to avoid them and build-time flags you can change.
CONFIG_ASYNC_TCP_MAX_ACK_TIME
- defines a timeout for TCP connection to be considered alive when waiting for data.In some bad network conditions you might consider increasing it.
CONFIG_ASYNC_TCP_QUEUE_SIZE
- defines the length of the queue for events related to connections handling.Both the server and AsyncTCP library were optimized to control the queue automatically. Do NOT try blindly increasing the queue size, it does not help you in a way you might think it is. If you receive debug messages about queue throttling, try to optimize your server callbacks code to execute as fast as possible.Read #165 thread, it might give you some hints.
CONFIG_ASYNC_TCP_RUNNING_CORE
- CPU core thread affinity that runs the queue events handling and executes server callbacks. Default is ANY core, so it means that for dualcore SoCs both cores could handle server activities. If your server's code is too heavy and unoptimized or you see that sometimesserver might affect other network activities, you might consider to bind it to the same core that runs Arduino code (1) to minimize affect on radio part. Otherwise you can leave the default to let RTOS decide where to run the thread based on priority
CONFIG_ASYNC_TCP_STACK_SIZE
- stack size for the thread that runs sever events and callbacks. Default is 16k that is a way too much waste for well-defined short async code or simple static file handling. You might want to cosider reducing it to 4-8k to same RAM usage. If you do not know what this is or not sure about your callback code demands - leave it as default, should be enough even for very hungry callbacks in most cases.
Note
This relates to ESP32 only, ESP8266 uses different ESPAsyncTCP lib that does not has this build options
I personally use the following configuration in my projects:
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000// (keep default) -D CONFIG_ASYNC_TCP_PRIORITY=10// (keep default) -D CONFIG_ASYNC_TCP_QUEUE_SIZE=64// (keep default) -D CONFIG_ASYNC_TCP_RUNNING_CORE=1// force async_tcp task to be on same core as Arduino app (default is any core) -D CONFIG_ASYNC_TCP_STACK_SIZE=4096// reduce the stack size (default is 16K)
If you need to serve chunk requests with a really low buffer (which should be avoided), you can set-D ASYNCWEBSERVER_USE_CHUNK_INFLIGHT=0
to disable the in-flight control.
About
Async Web Server for ESP32
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- C++98.8%
- Other1.2%