Skip to content

Commit

Permalink
Merge pull request letscontrolit#5181 from TD-er/bugfix/stalled_webpa…
Browse files Browse the repository at this point in the history
…ge_loading

[Webserver] Fix stalled web requests and not saving rules via Ethernet
  • Loading branch information
TD-er authored Dec 16, 2024
2 parents 13555c1 + ff979d3 commit 2a91472
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
7 changes: 4 additions & 3 deletions platformio_core_defs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extra_scripts = ${esp82xx_common.extra_scripts}
; For MUSTFIX_CLIENT_TIMEOUT_IN_SECONDS See: https://github.com/espressif/arduino-esp32/pull/6676
[core_esp32_IDF5_1_4__3_0_5_SPIFFS]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.09.10/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3110/framework-arduinoespressif32-all-release_v5.1-632e0c2.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3202/framework-arduinoespressif32-all-release_v5.1-41a885b.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
-DLIBRARIES_NO_LOG=1
Expand Down Expand Up @@ -197,8 +197,9 @@ lib_extra_dirs =

; ESP_IDF 5.3.1
[core_esp32_IDF5_3_1__3_0_5_LittleFS]
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3112/framework-arduinoespressif32-all-release_v5.3-1c74f314.zip
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3203/framework-arduinoespressif32-all-release_v5.3-ddc10306.zip
build_flags = -DESP32_STAGE
-DESP_IDF_VERSION_MAJOR=5
-DLIBRARIES_NO_LOG=1
Expand Down
5 changes: 3 additions & 2 deletions platformio_esp32_solo1.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
; IDF 5.3.1
[esp32_solo1_common_LittleFS]
extends = esp32_base_idf5
platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.10.31/platform-espressif32.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3113/framework-arduinoespressif32-solo1-release_v5.3-1c74f314.zip
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF53
;platform = https://github.com/tasmota/platform-espressif32/releases/download/2024.12.30/platform-espressif32.zip
platform_packages = framework-arduino-solo1 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/3204/framework-arduinoespressif32-solo1-release_v5.3-ddc10306.zip
build_flags = ${esp32_base_idf5.build_flags}
-DFEATURE_ARDUINO_OTA=1
-DUSE_LITTLEFS
Expand Down
8 changes: 7 additions & 1 deletion src/src/DataStructs/Web_StreamingBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ void Web_StreamingBuffer::startStream(bool allowOriginAll,
sentBytes = 0;
buf.clear();
buf.reserve(CHUNKED_BUFFER_SIZE);
web_server.client().setNoDelay(true);
#ifdef ESP32
web_server.client().setSSE(false);
#endif

if (beforeTXRam < 3000) {
lowMemorySkip = true;
Expand Down Expand Up @@ -290,6 +294,7 @@ void Web_StreamingBuffer::endStream() {
lowMemorySkip = false;
}
delay(5);
// web_server.client().stop();
}


Expand Down Expand Up @@ -402,7 +407,7 @@ void Web_StreamingBuffer::sendHeaderBlocking(bool allowOriginAll,
web_server.sendHeader(F("Access-Control-Allow-Origin"), origin);
}
web_server.send(httpCode, content_type, EMPTY_STRING);

#ifdef ESP8266
// dont wait on 2.3.0. Memory returns just too slow.
while ((ESP.getFreeHeap() < freeBeforeSend) &&
!timeOutReached(beginWait + timeout)) {
Expand All @@ -411,6 +416,7 @@ void Web_StreamingBuffer::sendHeaderBlocking(bool allowOriginAll,
#endif
delay(1);
}
#endif
#endif // if defined(ESP8266) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
delay(0);
}
3 changes: 2 additions & 1 deletion src/src/ESPEasyCore/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ bool MQTTConnect(controllerIndex_t controller_idx)

// mqtt = WiFiClient(); // workaround see: https://github.com/esp8266/Arduino/issues/4497#issuecomment-373023864
delay(0);
# if FEATURE_MQTT_TLS

uint16_t mqttPort = ControllerSettings->Port;

# if FEATURE_MQTT_TLS
mqtt_tls_last_errorstr.clear();
mqtt_tls_last_error = 0;
const TLS_types TLS_type = ControllerSettings->TLStype();
Expand Down
2 changes: 2 additions & 0 deletions src/src/WebServer/Rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ void Rule_showRuleTextArea(const String& fileName) {
addHtml(F("<textarea id='rules' name='rules' rows='30' wrap='off'>"));
size = streamFromFS(fileName, true);
addHtml(F("</textarea>"));
#if FEATURE_RULES_EASY_COLOR_CODE
addHtml(F("<script>initCM();</script>"));
#endif

html_TR_TD();
addHtml(F("Current size: <span id='size'>"));
Expand Down

0 comments on commit 2a91472

Please sign in to comment.