You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
-[Important recommendations for build options](#important-recommendations-for-build-options)
22
22
-[`AsyncWebSocketMessageBuffer` and `makeBuffer()`](#asyncwebsocketmessagebuffer-and-makebuffer)
23
23
-[How to replace a response](#how-to-replace-a-response)
24
24
-[How to use Middleware](#how-to-use-middleware)
@@ -48,6 +48,7 @@ This fork is based on [yubox-node-org/ESPAsyncWebServer](https://github.com/yubo
48
48
- (perf) `setCloseClientOnQueueFull(bool)` which can be set on a client to either close the connection or discard messages but not close the connection when the queue is full
49
49
- (perf) `SSE_MAX_QUEUED_MESSAGES` to control the maximum number of messages that can be queued for a SSE client
50
50
- (perf) `WS_MAX_QUEUED_MESSAGES`: control the maximum number of messages that can be queued for a Websocket client
51
+
- (perf) in-flight buffer control and queue congestion avoidance to help to improve parallel connections handling, high volume data transfers and mitigate poor implemeneted slow user-code callbacks delayes on connctions handling
51
52
- (perf) Code size improvements
52
53
- (perf) Lot of code cleanup and optimizations
53
54
- (perf) Performance improvements in terms of memory, speed and size
@@ -56,7 +57,7 @@ This fork is based on [yubox-node-org/ESPAsyncWebServer](https://github.com/yubo
56
57
57
58
## WARNING: Important notes about future version 4.x
58
59
59
-
This ESPAsyncWebServer fork is now at version 3.x.
60
+
This ESPAsyncWebServer fork is now at version 3.x, where we try to keep the API compatibility with original project as much as possible.
60
61
61
62
Next version 4.x will:
62
63
@@ -68,7 +69,8 @@ So if you need one of these feature, you will have to stick with 3.x or another
68
69
69
70
## Dependencies
70
71
71
-
**WARNING** The library name was changed from `ESP Async WebServer` to `ESPAsyncWebServer` as per the Arduino Lint recommendations, but its name had to stay `ESP Async WebServer` in Arduino Registry.
72
+
> [!WARNING]
73
+
> The library name was changed from `ESP Async WebServer` to `ESPAsyncWebServer` as per the Arduino Lint recommendations, but its name had to stay `ESP Async WebServer` in Arduino Registry.
72
74
73
75
**PlatformIO / pioarduino:**
74
76
@@ -158,26 +160,41 @@ Test is running for 20 seconds with 10 connections.
158
160
// Total: 2038 events, 509.50 events / second
159
161
```
160
162
161
-
## Important recommendations
163
+
## Important recommendations for build options
162
164
163
-
Most of the crashes are caused by improper configuration of the library for the project.
164
-
Here are some recommendations to avoid them.
165
+
Most of the crashes are caused by improper use or configuration of the AsyncTCP library used for the project.
166
+
Here are some recommendations to avoid them and build-time flags you can change.
167
+
168
+
`CONFIG_ASYNC_TCP_MAX_ACK_TIME` - defines a timeout for TCP connection to be considered alive when waiting for data.
169
+
In some bad network conditions you might consider increasing it.
170
+
171
+
`CONFIG_ASYNC_TCP_QUEUE_SIZE` - defines the length of the queue for events related to connections handling.
172
+
Both the server and AsyncTCP library in this fork 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 callbaks code to execute as fast as possible.
173
+
Read #165 thread, it might give you some hints.
174
+
175
+
`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 sometimes
176
+
server 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
177
+
178
+
`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.
179
+
180
+
> [!NOTE]
181
+
> This relates to ESP32 only, ESP8266 uses different ESPAsyncTCP lib that does not has this build options
165
182
166
183
I personally use the following configuration in my projects:
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1// force async_tcp task to be on same core as Arduino app (default is any core)
190
+
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096// reduce the stack size (default is 16K)
174
191
```
175
192
176
193
## `AsyncWebSocketMessageBuffer` and `makeBuffer()`
177
194
178
-
The fork from `yubox-node-org` introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
195
+
The fork from [yubox-node-org](https://github.com/yubox-node-org/ESPAsyncWebServer) introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
179
196
180
-
This fork is compatible with the original library from `me-no-dev` regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
197
+
This fork is compatible with the original library from [me-no-dev](https://github.com/me-no-dev/ESPAsyncWebServer) regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
181
198
So you have the choice of which API to use.
182
199
183
200
Here are examples for serializing a Json document in a websocket message buffer:
@@ -298,8 +315,17 @@ myHandler.addMiddleware(&authMiddleware); // add authentication to a specific ha
298
315
These callbacks can be called multiple times during request parsing, so this is up to the user to now call the `AuthenticationMiddleware.allowed(request)` if needed and ideally when the method is called for the first time.
299
316
These callbacks are also not triggering the whole middleware chain since they are not part of the request processing workflow (they are not the final handler).
300
317
301
-
## Original Documentation
302
318
319
+
## Maintainers
320
+
This fork of ESPAsyncWebServer and dependend libs are maintained as an opensource project at best effort level.
-[Important recommendations for build options](#important-recommendations-for-build-options)
22
22
-[`AsyncWebSocketMessageBuffer` and `makeBuffer()`](#asyncwebsocketmessagebuffer-and-makebuffer)
23
23
-[How to replace a response](#how-to-replace-a-response)
24
24
-[How to use Middleware](#how-to-use-middleware)
@@ -48,6 +48,7 @@ This fork is based on [yubox-node-org/ESPAsyncWebServer](https://github.com/yubo
48
48
- (perf) `setCloseClientOnQueueFull(bool)` which can be set on a client to either close the connection or discard messages but not close the connection when the queue is full
49
49
- (perf) `SSE_MAX_QUEUED_MESSAGES` to control the maximum number of messages that can be queued for a SSE client
50
50
- (perf) `WS_MAX_QUEUED_MESSAGES`: control the maximum number of messages that can be queued for a Websocket client
51
+
- (perf) in-flight buffer control and queue congestion avoidance to help to improve parallel connections handling, high volume data transfers and mitigate poor implemeneted slow user-code callbacks delayes on connctions handling
51
52
- (perf) Code size improvements
52
53
- (perf) Lot of code cleanup and optimizations
53
54
- (perf) Performance improvements in terms of memory, speed and size
@@ -56,7 +57,7 @@ This fork is based on [yubox-node-org/ESPAsyncWebServer](https://github.com/yubo
56
57
57
58
## WARNING: Important notes about future version 4.x
58
59
59
-
This ESPAsyncWebServer fork is now at version 3.x.
60
+
This ESPAsyncWebServer fork is now at version 3.x, where we try to keep the API compatibility with original project as much as possible.
60
61
61
62
Next version 4.x will:
62
63
@@ -68,7 +69,8 @@ So if you need one of these feature, you will have to stick with 3.x or another
68
69
69
70
## Dependencies
70
71
71
-
**WARNING** The library name was changed from `ESP Async WebServer` to `ESPAsyncWebServer` as per the Arduino Lint recommendations, but its name had to stay `ESP Async WebServer` in Arduino Registry.
72
+
> [!WARNING]
73
+
> The library name was changed from `ESP Async WebServer` to `ESPAsyncWebServer` as per the Arduino Lint recommendations, but its name had to stay `ESP Async WebServer` in Arduino Registry.
72
74
73
75
**PlatformIO / pioarduino:**
74
76
@@ -158,26 +160,41 @@ Test is running for 20 seconds with 10 connections.
158
160
// Total: 2038 events, 509.50 events / second
159
161
```
160
162
161
-
## Important recommendations
163
+
## Important recommendations for build options
162
164
163
-
Most of the crashes are caused by improper configuration of the library for the project.
164
-
Here are some recommendations to avoid them.
165
+
Most of the crashes are caused by improper use or configuration of the AsyncTCP library used for the project.
166
+
Here are some recommendations to avoid them and build-time flags you can change.
167
+
168
+
`CONFIG_ASYNC_TCP_MAX_ACK_TIME` - defines a timeout for TCP connection to be considered alive when waiting for data.
169
+
In some bad network conditions you might consider increasing it.
170
+
171
+
`CONFIG_ASYNC_TCP_QUEUE_SIZE` - defines the length of the queue for events related to connections handling.
172
+
Both the server and AsyncTCP library in this fork 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 callbaks code to execute as fast as possible.
173
+
Read #165 thread, it might give you some hints.
174
+
175
+
`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 sometimes
176
+
server 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
177
+
178
+
`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.
179
+
180
+
> [!NOTE]
181
+
> This relates to ESP32 only, ESP8266 uses different ESPAsyncTCP lib that does not has this build options
165
182
166
183
I personally use the following configuration in my projects:
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1// force async_tcp task to be on same core as Arduino app (default is any core)
190
+
-D CONFIG_ASYNC_TCP_STACK_SIZE=4096// reduce the stack size (default is 16K)
174
191
```
175
192
176
193
## `AsyncWebSocketMessageBuffer` and `makeBuffer()`
177
194
178
-
The fork from `yubox-node-org` introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
195
+
The fork from [yubox-node-org](https://github.com/yubox-node-org/ESPAsyncWebServer) introduces some breaking API changes compared to the original library, especially regarding the use of `std::shared_ptr<std::vector<uint8_t>>` for WebSocket.
179
196
180
-
This fork is compatible with the original library from `me-no-dev` regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
197
+
This fork is compatible with the original library from [me-no-dev](https://github.com/me-no-dev/ESPAsyncWebServer) regarding WebSocket, and wraps the optimizations done by `yubox-node-org` in the `AsyncWebSocketMessageBuffer` class.
181
198
So you have the choice of which API to use.
182
199
183
200
Here are examples for serializing a Json document in a websocket message buffer:
@@ -298,8 +315,17 @@ myHandler.addMiddleware(&authMiddleware); // add authentication to a specific ha
298
315
These callbacks can be called multiple times during request parsing, so this is up to the user to now call the `AuthenticationMiddleware.allowed(request)` if needed and ideally when the method is called for the first time.
299
316
These callbacks are also not triggering the whole middleware chain since they are not part of the request processing workflow (they are not the final handler).
300
317
301
-
## Original Documentation
302
318
319
+
## Maintainers
320
+
This fork of ESPAsyncWebServer and dependend libs are maintained as an opensource project at best effort level.
0 commit comments