I am using a HTTP Client inside loop to check for the body of a URL.
Today the ESP crashed and restarted. After the restart it connected to the WiFi using the provided SSID and Password, so using DHCP. But it behaved like it did not connect.
The web-pages that I have on the ESPAsyncWebServer didn't work.
And I repeatedly got:
Code: Select all
[E][WiFiGeneric.cpp:658] hostByName(): DNS Failed
[HTTP] GET... failed, error: connection refused
Code: Select all
if (WiFi.status() == WL_CONNECTED && SPIFFS.exists("/configFile.txt")) { //Check the current connection status
if(URL.length() > 15) {
HTTPClient http;
http.begin(URL); //Specify the URL
int httpCode = http.GET(); //Make the request
if (httpCode > 0) { //Check for the returning code
logOutput((String)"[HTTP] GET... code: " + httpCode);
if(httpCode == HTTP_CODE_OK) {
String payload = http.getString();
logOutput(payload);
signPlace = getPlaces(payload);
oldSignPlace = signPlace;
}
} else {
logOutput((String)"[HTTP] GET... failed, error: " + http.errorToString(httpCode).c_str());
}
http.end(); //Free the resources
} else {
logOutput("URL Link is invalid ! Please enter another URL");
}
} // if (WiFi.status() == WL_CONNECTED)
The real problem is that it happened even when I was the one who restarted the ESP.