Skip to content
This repository was archived by the owner on Jan 21, 2025. It is now read-only.

Commit a00cf38

Browse files
authored
Merge branch 'main' into buffcredit
2 parents 3d3456e + 61eed0e commit a00cf38

6 files changed

Lines changed: 104 additions & 131 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Install AsyncTCP (ESP32)
5757
if: ${{ matrix.core == 'esp32:esp32' }}
58-
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/AsyncTCP#v3.2.14
58+
run: ARDUINO_LIBRARY_ENABLE_UNSAFE_INSTALL=true arduino-cli lib install --git-url https://github.com/mathieucarbou/AsyncTCP#v3.2.15
5959

6060
- name: Install ESPAsyncTCP (ESP8266)
6161
if: ${{ matrix.core == 'esp8266:esp8266' }}

README.md

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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
9999
lib_compat_mode = strict
100100
lib_ldf_mode = chain
101101
lib_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
105105
lib_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

163163
Most of the crashes are caused by improper configuration of the library for the project.
164164
Here 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()`

docs/index.md

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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
9999
lib_compat_mode = strict
100100
lib_ldf_mode = chain
101101
lib_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
105105
lib_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

163163
Most of the crashes are caused by improper configuration of the library for the project.
164164
Here 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

624611
AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/rest/endpoint", [](AsyncWebServerRequest *request, JsonVariant &json) {
625-
JsonObject& jsonObj = json.as<JsonObject>();
612+
JsonObject jsonObj = json.as<JsonObject>();
626613
// ...
627614
});
628615
server.addHandler(handler);

examples/SimpleServer/SimpleServer.ino

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -676,52 +676,51 @@ void setup() {
676676
// launch 16 concurrent workers for 30 seconds
677677
// > for i in {1..16}; do ( count=$(gtimeout 30 curl -s -N -H "Accept: text/event-stream" http://192.168.4.1/events 2>&1 | grep -c "^data:"); echo "Total: $count events, $(echo "$count / 4" | bc -l) events / second" ) & done;
678678
//
679-
// With AsyncTCP, with 16 workers: a lot of Too many messages queued: deleting message
679+
// With AsyncTCP, with 16 workers: a lot of "Event message queue overflow: discard message", no crash
680680
//
681-
// Total: 119 events, 29.75000000000000000000 events / second
682-
// Total: 727 events, 181.75000000000000000000 events / second
683-
// Total: 1386 events, 346.50000000000000000000 events / second
684-
// Total: 1385 events, 346.25000000000000000000 events / second
685-
// Total: 1276 events, 319.00000000000000000000 events / second
686-
// Total: 1411 events, 352.75000000000000000000 events / second
687-
// Total: 1276 events, 319.00000000000000000000 events / second
688-
// Total: 1333 events, 333.25000000000000000000 events / second
689-
// Total: 1250 events, 312.50000000000000000000 events / second
690-
// Total: 1275 events, 318.75000000000000000000 events / second
691-
// Total: 1271 events, 317.75000000000000000000 events / second
692-
// Total: 1271 events, 317.75000000000000000000 events / second
693-
// Total: 1254 events, 313.50000000000000000000 events / second
694-
// Total: 1251 events, 312.75000000000000000000 events / second
695-
// Total: 1254 events, 313.50000000000000000000 events / second
696-
// Total: 1262 events, 315.50000000000000000000 events / second
681+
// Total: 1711 events, 427.75 events / second
682+
// Total: 1711 events, 427.75 events / second
683+
// Total: 1626 events, 406.50 events / second
684+
// Total: 1562 events, 390.50 events / second
685+
// Total: 1706 events, 426.50 events / second
686+
// Total: 1659 events, 414.75 events / second
687+
// Total: 1624 events, 406.00 events / second
688+
// Total: 1706 events, 426.50 events / second
689+
// Total: 1487 events, 371.75 events / second
690+
// Total: 1573 events, 393.25 events / second
691+
// Total: 1569 events, 392.25 events / second
692+
// Total: 1559 events, 389.75 events / second
693+
// Total: 1560 events, 390.00 events / second
694+
// Total: 1562 events, 390.50 events / second
695+
// Total: 1626 events, 406.50 events / second
697696
//
698697
// With AsyncTCP, with 10 workers:
699698
//
700-
// Total: 1875 events, 468.75000000000000000000 events / second
701-
// Total: 1870 events, 467.50000000000000000000 events / second
702-
// Total: 1871 events, 467.75000000000000000000 events / second
703-
// Total: 1875 events, 468.75000000000000000000 events / second
704-
// Total: 1871 events, 467.75000000000000000000 events / second
705-
// Total: 1805 events, 451.25000000000000000000 events / second
706-
// Total: 1803 events, 450.75000000000000000000 events / second
707-
// Total: 1873 events, 468.25000000000000000000 events / second
708-
// Total: 1872 events, 468.00000000000000000000 events / second
709-
// Total: 1805 events, 451.25000000000000000000 events / second
699+
// Total: 2038 events, 509.50 events / second
700+
// Total: 2120 events, 530.00 events / second
701+
// Total: 2119 events, 529.75 events / second
702+
// Total: 2038 events, 509.50 events / second
703+
// Total: 2037 events, 509.25 events / second
704+
// Total: 2119 events, 529.75 events / second
705+
// Total: 2119 events, 529.75 events / second
706+
// Total: 2120 events, 530.00 events / second
707+
// Total: 2038 events, 509.50 events / second
708+
// Total: 2038 events, 509.50 events / second
710709
//
711710
// With AsyncTCPSock, with 16 workers: ESP32 CRASH !!!
712711
//
713712
// With AsyncTCPSock, with 10 workers:
714713
//
715-
// Total: 1242 events, 310.50000000000000000000 events / second
716-
// Total: 1242 events, 310.50000000000000000000 events / second
717-
// Total: 1242 events, 310.50000000000000000000 events / second
718-
// Total: 1242 events, 310.50000000000000000000 events / second
719-
// Total: 1181 events, 295.25000000000000000000 events / second
720-
// Total: 1182 events, 295.50000000000000000000 events / second
721-
// Total: 1240 events, 310.00000000000000000000 events / second
722-
// Total: 1181 events, 295.25000000000000000000 events / second
723-
// Total: 1181 events, 295.25000000000000000000 events / second
724-
// Total: 1183 events, 295.75000000000000000000 events / second
714+
// Total: 1242 events, 310.50 events / second
715+
// Total: 1242 events, 310.50 events / second
716+
// Total: 1242 events, 310.50 events / second
717+
// Total: 1242 events, 310.50 events / second
718+
// Total: 1181 events, 295.25 events / second
719+
// Total: 1182 events, 295.50 events / second
720+
// Total: 1240 events, 310.00 events / second
721+
// Total: 1181 events, 295.25 events / second
722+
// Total: 1181 events, 295.25 events / second
723+
// Total: 1183 events, 295.75 events / second
725724
//
726725
server.addHandler(&events);
727726

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{
2929
"owner": "mathieucarbou",
3030
"name": "AsyncTCP",
31-
"version": "^3.2.14",
31+
"version": "^3.2.15",
3232
"platforms": "espressif32"
3333
},
3434
{

platformio.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ build_flags =
1616
-Wno-unused-parameter
1717
-D CONFIG_ARDUHAL_LOG_COLORS
1818
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
19-
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=3000
19+
-D CONFIG_ASYNC_TCP_MAX_ACK_TIME=5000
2020
-D CONFIG_ASYNC_TCP_PRIORITY=10
21-
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
21+
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=64
2222
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
2323
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096
2424
upload_protocol = esptool
@@ -31,7 +31,7 @@ lib_deps =
3131
; bblanchon/ArduinoJson @ 5.13.4
3232
; bblanchon/ArduinoJson @ 6.21.5
3333
bblanchon/ArduinoJson @ 7.2.1
34-
mathieucarbou/AsyncTCP @ 3.2.14
34+
mathieucarbou/AsyncTCP @ 3.2.15
3535
board = esp32dev
3636
board_build.partitions = partitions-4MB.csv
3737
board_build.filesystem = littlefs
@@ -49,7 +49,7 @@ platform = https://github.com/pioarduino/platform-espressif32/releases/download/
4949
; board = esp32-s3-devkitc-1
5050
; board = esp32-c6-devkitc-1
5151
lib_deps =
52-
mathieucarbou/AsyncTCP @ 3.2.14
52+
mathieucarbou/AsyncTCP @ 3.2.15
5353

5454
[env:arduino-310]
5555
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10-rc3/platform-espressif32.zip
@@ -102,7 +102,7 @@ board = ${sysenv.PIO_BOARD}
102102
platform = https://github.com/pioarduino/platform-espressif32/releases/download/51.03.05/platform-espressif32.zip
103103
board = ${sysenv.PIO_BOARD}
104104
lib_deps =
105-
mathieucarbou/AsyncTCP @ 3.2.14
105+
mathieucarbou/AsyncTCP @ 3.2.15
106106

107107
[env:ci-arduino-310]
108108
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.10-rc3/platform-espressif32.zip

0 commit comments

Comments
 (0)