Getting `[E][WiFiGeneric.cpp:658] hostByName(): DNS Failed` randomly

GeorgeFlorian1
Posts: 160
Joined: Thu Jan 31, 2019 2:32 pm

Getting `[E][WiFiGeneric.cpp:658] hostByName(): DNS Failed` randomly

Postby GeorgeFlorian1 » Tue May 14, 2019 2:06 pm

Hello !

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
This is a part of the code that runs in void loop():

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 only fix is to restart again !
The real problem is that it happened even when I was the one who restarted the ESP.

Who is online

Users browsing this forum: No registered users and 76 guests