Closed
Description
Basic Infos
Hardware
Hardware: Wemos D1 mini Pro
Core Version: 2.3.0
Description
When the ESPhttpUpdate starts downloading the requested file, all ESP8266WebServer connections seem to close. As such, sending a message to a client stating the update was done successfully cannot be achieved.
In the example code, if the server fails supplying the file, or sends a 304 request, the result propagates to the client requesting via POST the /esp endpoint. But if the server supplies the file, the connnection is terminated, the client basically having to deal with an ERR_EMPTY_RESPONSE.
Sketch
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266httpUpdate.h>
ESP8266WebServer _web_server;
void setup() {
WiFi.softAP("MyESP");
ESPhttpUpdate.rebootOnUpdate(false);
_web_server.on("/esp", HTTP_POST, [&](){
HTTPUpdateResult ret = ESPhttpUpdate.update(_web_server.arg("firmware"), "1.0.0");
switch(ret) {
case HTTP_UPDATE_FAILED:
PREi::sendJSON(500, "Update failed.");
break;
case HTTP_UPDATE_NO_UPDATES:
PREi::sendJSON(304, "Update not necessary.");
break;
case HTTP_UPDATE_OK:
PREi::sendJSON(200, "Update started.");
ESP.restart();
break;
}
});
}
void loop() {
_web_server.handleClient();
yield();
}
Metadata
Metadata
Assignees
Labels
No labels