@@ -80,8 +80,8 @@ lib_deps = mathieucarbou/ESPAsyncWebServer @ 3.4.0
8080
8181** Dependencies:**
8282
83- - ** ESP32 with AsyncTCP** : ` mathieucarbou/AsyncTCP @ 3.2.14 `
84- Arduino IDE: [ https://github.com/mathieucarbou/AsyncTCP#v3.2.14 ] ( https://github.com/mathieucarbou/AsyncTCP/releases )
83+ - ** ESP32 with AsyncTCP** : ` mathieucarbou/AsyncTCP @ 3.2.15 `
84+ Arduino IDE: [ https://github.com/mathieucarbou/AsyncTCP#v3.2.15 ] ( https://github.com/mathieucarbou/AsyncTCP/releases )
8585
8686- ** ESP32 with AsyncTCPSock** : ` https://github.com/mathieucarbou/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip `
8787
@@ -99,7 +99,7 @@ AsyncTCPSock can be used instead of AsyncTCP by excluding AsyncTCP from the libr
9999lib_compat_mode = strict
100100lib_ldf_mode = chain
101101lib_deps =
102- ; mathieucarbou/AsyncTCP @ 3.2.14
102+ ; mathieucarbou/AsyncTCP @ 3.2.15
103103 https://github.com/mathieucarbou/AsyncTCPSock/archive/refs/tags/v1.0.3-dev.zip
104104 mathieucarbou/ESPAsyncWebServer @ 3.4.0
105105lib_ignore =
@@ -116,7 +116,7 @@ Performance of `mathieucarbou/ESPAsyncWebServer @ 3.4.0`:
116116> autocannon -c 10 -w 10 -d 20 http://192.168.4.1
117117```
118118
119- With ` mathieucarbou/AsyncTCP @ 3.2.14 `
119+ With ` mathieucarbou/AsyncTCP @ 3.2.15 `
120120
121121[ ![ ] ( https://mathieu.carbou.me/ESPAsyncWebServer/perf-c10.png )] ( https://mathieu.carbou.me/ESPAsyncWebServer/perf-c10.png )
122122
@@ -133,57 +133,44 @@ Test is running for 20 seconds with 10 connections.
133133```
134134// With AsyncTCP, with 10 workers: no message discarded from the queue
135135//
136- // Total: 1875 events, 468.75000000000000000000 events / second
137- // Total: 1870 events, 467.50000000000000000000 events / second
138- // Total: 1871 events, 467.75000000000000000000 events / second
139- // Total: 1875 events, 468.75000000000000000000 events / second
140- // Total: 1871 events, 467.75000000000000000000 events / second
141- // Total: 1805 events, 451.25000000000000000000 events / second
142- // Total: 1803 events, 450.75000000000000000000 events / second
143- // Total: 1873 events, 468.25000000000000000000 events / second
144- // Total: 1872 events, 468.00000000000000000000 events / second
145- // Total: 1805 events, 451.25000000000000000000 events / second
136+ // Total: 2038 events, 509.50 events / second
137+ // Total: 2120 events, 530.00 events / second
138+ // Total: 2119 events, 529.75 events / second
139+ // Total: 2038 events, 509.50 events / second
140+ // Total: 2037 events, 509.25 events / second
141+ // Total: 2119 events, 529.75 events / second
142+ // Total: 2119 events, 529.75 events / second
143+ // Total: 2120 events, 530.00 events / second
144+ // Total: 2038 events, 509.50 events / second
145+ // Total: 2038 events, 509.50 events / second
146146//
147147// With AsyncTCPSock, with 10 workers: no message discarded from the queue
148148//
149- // Total: 1242 events, 310.50000000000000000000 events / second
150- // Total: 1242 events, 310.50000000000000000000 events / second
151- // Total: 1242 events, 310.50000000000000000000 events / second
152- // Total: 1242 events, 310.50000000000000000000 events / second
153- // Total: 1181 events, 295.25000000000000000000 events / second
154- // Total: 1182 events, 295.50000000000000000000 events / second
155- // Total: 1240 events, 310.00000000000000000000 events / second
156- // Total: 1181 events, 295.25000000000000000000 events / second
157- // Total: 1181 events, 295.25000000000000000000 events / second
158- // Total: 1183 events, 295.75000000000000000000 events / second
149+ // Total: 2038 events, 509.50 events / second
150+ // Total: 2120 events, 530.00 events / second
151+ // Total: 2119 events, 529.75 events / second
152+ // Total: 2038 events, 509.50 events / second
153+ // Total: 2037 events, 509.25 events / second
154+ // Total: 2119 events, 529.75 events / second
155+ // Total: 2119 events, 529.75 events / second
156+ // Total: 2120 events, 530.00 events / second
157+ // Total: 2038 events, 509.50 events / second
158+ // Total: 2038 events, 509.50 events / second
159159```
160160
161161## Important recommendations
162162
163163Most of the crashes are caused by improper configuration of the library for the project.
164164Here are some recommendations to avoid them.
165165
166- 1 . Set the running core to be on the same core of your application (usually core 1) ` -D CONFIG_ASYNC_TCP_RUNNING_CORE=1 `
167- 2 . Set the stack size appropriately with ` -D CONFIG_ASYNC_TCP_STACK_SIZE=16384 ` .
168- The default value of ` 16384 ` might be too much for your project.
169- You can look at the [ MycilaTaskMonitor] ( https://mathieu.carbou.me/MycilaTaskMonitor ) project to monitor the stack usage.
170- 3 . You can change ** if you know what you are doing** the task priority with ` -D CONFIG_ASYNC_TCP_PRIORITY=10 ` .
171- Default is ` 10 ` .
172- 4 . You can increase the queue size with ` -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128 ` .
173- Default is ` 64 ` .
174- 5 . You can decrease the maximum ack time ` -D CONFIG_ASYNC_TCP_MAX_ACK_TIME=3000 ` .
175- Default is ` 5000 ` .
176-
177- I personally use the following configuration in my projects because my WS messages can be big (up to 4k).
178- If you have smaller messages, you can increase ` WS_MAX_QUEUED_MESSAGES ` to 128.
166+ I personally use the following configuration in my projects:
179167
180168``` c++
181- -D CONFIG_ASYNC_TCP_MAX_ACK_TIME =3000
182- -D CONFIG_ASYNC_TCP_PRIORITY =10
183- -D CONFIG_ASYNC_TCP_QUEUE_SIZE =128
184- -D CONFIG_ASYNC_TCP_RUNNING_CORE =1
185- -D CONFIG_ASYNC_TCP_STACK_SIZE =4096
186- -D WS_MAX_QUEUED_MESSAGES =64
169+ -D CONFIG_ASYNC_TCP_MAX_ACK_TIME =5000 // (keep default)
170+ -D CONFIG_ASYNC_TCP_PRIORITY =10 // (keep default)
171+ -D CONFIG_ASYNC_TCP_QUEUE_SIZE =64 // (keep default)
172+ -D CONFIG_ASYNC_TCP_RUNNING_CORE =1 // force async_tcp task to be on same core as the app (default is core 0)
173+ -D CONFIG_ASYNC_TCP_STACK_SIZE =4096 // reduce the stack size (default is 16K)
187174```
188175
189176## ` AsyncWebSocketMessageBuffer ` and ` makeBuffer() `
@@ -622,7 +609,7 @@ Endpoints which consume JSON can use a special handler to get ready to use JSON
622609#include " ArduinoJson.h"
623610
624611AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler(" /rest/endpoint" , [](AsyncWebServerRequest *request, JsonVariant &json) {
625- JsonObject& jsonObj = json.as<JsonObject >();
612+ JsonObject jsonObj = json.as<JsonObject >();
626613 // ...
627614});
628615server.addHandler(handler);
0 commit comments