Open
Description
Basic Infos
- [ x ] This issue complies with the issue POLICY doc.
- [ x ] I have read the documentation at readthedocs and the issue is not addressed there.
- [ x ] I have tested that the issue is present in current master branch (aka latest git).
- [ x ] I have searched the issue tracker for a similar issue.
- [ x ] If there is a stack dump, I have decoded it.
- [ x ] I have filled out all fields below.
Platform
- Hardware: [ESP-12]
- Core Version: [3.0.2]
- Development Env: [Arduino IDE]
- Operating System: [Windows]
Settings in IDE
- Module: [Generic ESP8266 Module]
- Flash Mode: [DOUT]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [dtr]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200]
Problem Description
I have a separate router and modem.
After temporary data loss (modem disconnected, internet reconnection, etc), without WiFi connection loss ESP DNS cant solve any IP addresses.
I have enabled the DEBUG level to WIFI.
Sketch
#include <ESP8266WiFi.h>
const char* ssid = "my-ssid";
const char* password = "my-password";
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
IPAddress ipResult;
int result = WiFi.hostByName("www.google.com", ipResult);
Serial.print("Result: "); Serial.println(result);
Serial.print("Ip: "); Serial.println(ipResult);
Serial.println();
delay(5000);
}
Turn on the router WITHOUT DATA (modem connection), and start the ESP.
The output, as expected, is this:
[hostByName] request IP for: www.google.com
[hostByName] Host: www.google.com lookup error: -5!
Result: 0
Ip: (IP unset)
But after data reestablishing (connecting the router to the modem), ESP still cannot resolve the IP address.
I know there is a DNS cache (I don't know exactly how long it lasts), but I left it running for 24 hours and the output remained the same.
I tried some actions, like reconnecting to WiFi, but is only solves if I restart the device.