Skip to content

Commit

Permalink
added debug logs for issue #172 (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Dec 19, 2024
1 parent 7f0154c commit 48f80d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/SimpleServer/SimpleServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ uint32_t deltaSSE = 10;
uint32_t lastWS = 0;
uint32_t deltaWS = 100;

uint32_t lastHeap = 0;

void loop() {
uint32_t now = millis();
if (now - lastSSE >= deltaSSE) {
Expand All @@ -779,4 +781,8 @@ void loop() {
// }
lastWS = millis();
}
if(now - lastHeap >= 2000) {
Serial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
lastHeap = now;
}
}
9 changes: 9 additions & 0 deletions src/WebRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ AsyncWebServerRequest::~AsyncWebServerRequest() {
}

void AsyncWebServerRequest::_onData(void* buf, size_t len) {
log_d("Request pointer: %p", this);
log_d("Free Heap: %u", ESP.getFreeHeap());

// SSL/TLS handshake detection
#ifndef ASYNC_TCP_SSL_ENABLED
if (_parseState == PARSE_REQ_START && len && ((uint8_t*)buf)[0] == 0x16) { // 0x16 indicates a Handshake message (SSL/TLS).
Expand Down Expand Up @@ -171,6 +174,7 @@ void AsyncWebServerRequest::_onData(void* buf, size_t len) {
}

void AsyncWebServerRequest::_onPoll() {
log_d("Request pointer: %p", this);
// os_printf("p\n");
if (_response != NULL && _client != NULL && _client->canSend()) {
if (!_response->_finished()) {
Expand All @@ -186,6 +190,7 @@ void AsyncWebServerRequest::_onPoll() {
}

void AsyncWebServerRequest::_onAck(size_t len, uint32_t time) {
log_d("Request pointer: %p, len: %u, time: %u", this, len, time);
// os_printf("a:%u:%u\n", len, time);
if (_response != NULL) {
if (!_response->_finished()) {
Expand All @@ -201,10 +206,12 @@ void AsyncWebServerRequest::_onAck(size_t len, uint32_t time) {
}

void AsyncWebServerRequest::_onError(int8_t error) {
log_d("Client error: %d", error);
(void)error;
}

void AsyncWebServerRequest::_onTimeout(uint32_t time) {
log_d("Client timeout: %u", time);
(void)time;
// os_printf("TIMEOUT: %u, state: %s\n", time, _client->stateToString());
_client->close();
Expand All @@ -215,6 +222,8 @@ void AsyncWebServerRequest::onDisconnect(ArDisconnectHandler fn) {
}

void AsyncWebServerRequest::_onDisconnect() {
log_d("Client disconnected");

// os_printf("d\n");
if (_onDisconnectfn) {
_onDisconnectfn();
Expand Down
1 change: 1 addition & 0 deletions src/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void AsyncWebServer::beginSecure(const char* cert, const char* key, const char*
#endif

void AsyncWebServer::_handleDisconnect(AsyncWebServerRequest* request) {
log_d("Deleting request pointer: %p", request);
delete request;
}

Expand Down

0 comments on commit 48f80d3

Please sign in to comment.