-
Notifications
You must be signed in to change notification settings - Fork 60
Fix client rx timeout #226
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
base: main
Are you sure you want to change the base?
Changes from all commits
1dbce42
a874dfb
db7c354
8e83931
43e62c0
a2b8307
b392f0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
#include <vector> | ||
|
||
#if defined(ESP32) || defined(LIBRETINY) | ||
#ifdef ESP32 | ||
#include "sdkconfig.h" | ||
#endif | ||
#include <AsyncTCP.h> | ||
#elif defined(ESP8266) | ||
#include <ESPAsyncTCP.h> | ||
|
@@ -44,6 +47,10 @@ | |
#define ASYNCWEBSERVER_USE_CHUNK_INFLIGHT 1 | ||
#endif | ||
|
||
#ifndef ASYNCWEBSERVER_RX_TIMEOUT | ||
#define ASYNCWEBSERVER_RX_TIMEOUT 3 // Seconds for timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be set to 0 (the default in AsyncTCP) for backward compatiblity right ? Ideally, AsyncTCP should even expose a constant macro that gets reused here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think so. Except connection ws and sse. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but there are some use cases such as long-lived connections or long polling where a normal request would be more like a sse / ws request. my second point is that it introduces a change compared to the current defaults. If some users rely on the current default, then this change can break their app. Also, another place where this timeout should be set to zero I think is when we decide to pause a request (there is a pause method in the code). So more generally, I think it could be better to just leave it to its current defaults and then issue a 3.8.0 release with this newly added feature , and we document in the wiki and release notes that there is a new extra timeout methods people can set. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @me-no-dev : any opinion on that ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In some cases, during file downloads or uploads, long connections may be lost or broken due to network issues. If timeout handling is disabled, the server may keep these connections indefinitely, leading to a memory leak.
This update does not change the design of the implemented Async WebServer; it only fixes incorrect RX timeout handling.
I understand that point, so the new update has implemented a mechanism to back up and restore the RX timeout.
The timeout method is not new—it is already implemented and based on AsyncTCP. The Async WebServer simply registers the onTimeout() callback and then decides whether to close the connection on its own. Thanks so much for your comments! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need a bit of time to check everything out |
||
#endif | ||
|
||
class AsyncWebServer; | ||
class AsyncWebServerRequest; | ||
class AsyncWebServerResponse; | ||
|
@@ -87,8 +94,13 @@ class FileOpenMode { | |
#endif | ||
|
||
// if this value is returned when asked for data, packet will not be sent and you will be asked for data again | ||
#define RESPONSE_TRY_AGAIN 0xFFFFFFFF | ||
#define RESPONSE_TRY_AGAIN 0xFFFFFFFF | ||
|
||
#ifndef CONFIG_TCP_MSS | ||
#define RESPONSE_STREAM_BUFFER_SIZE 1460 | ||
#else | ||
#define RESPONSE_STREAM_BUFFER_SIZE CONFIG_TCP_MSS | ||
TienHuyIoT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#endif | ||
|
||
typedef uint8_t WebRequestMethodComposite; | ||
typedef std::function<void(void)> ArDisconnectHandler; | ||
|
@@ -250,6 +262,7 @@ class AsyncWebServerRequest { | |
String _itemValue; | ||
uint8_t *_itemBuffer; | ||
size_t _itemBufferIndex; | ||
uint32_t _rx_timeout; | ||
bool _itemIsFile; | ||
|
||
void _onPoll(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.