Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it. (N/A)
- I have filled out all fields below.
Platform
- Hardware: ESP-12S
- Core Version: SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
- Development Env: PlatformIO
- Operating System: Windows
Settings in IDE
- Module: Wemos D1 mini r2
- Flash Mode: qio
- Flash Size: 4Mb
- lwip Variant: v2 Lower Memory
- Reset Method: ck
- Flash Frequency: 40Mhz
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 460800
Problem Description
This is a repost of #6639 with updated verbiage and MCVE.
hostByName resolution fails regularly with -5 when called with Ticker using mDNS. When Ticker is attached with a 5 second interval, it fails every other time. When called with a 2 second interval, it fails every 5th time.
When using DNS/Internet addresses, I cannot reproduce the issue.
MCVE Sketch
#include <ESP8266mDNS.h>
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <Arduino.h>
void setup() {
Serial.begin(74880);
Serial.setDebugOutput(true);
Serial.flush();
WiFi.begin(F("Xxxxxxxx"), F("xxxxxxxx"));
Serial.println();
Serial.print(F("Waiting for connection."));
while (WiFi.status() != WL_CONNECTED) {
Serial.print(F("."));
delay(500);
}
Serial.println();
Serial.println(F("Connected."));
Serial.print(F("DNS #1: "));
Serial.print(WiFi.dnsIP().toString().c_str());
Serial.print(F(", DNS #2: "));
Serial.println(WiFi.dnsIP(1).toString().c_str());
}
void loop() {
IPAddress resolvedIP;
const char* host = "raspberrypi.local";
if (!WiFi.hostByName(host, resolvedIP)) {
Serial.print(F("(Loop) Host lookup failed for "));
Serial.println(host);
} else {
Serial.print(F("(Loop) Host: "));
Serial.print(host);
Serial.print(", IP: ");
Serial.println(resolvedIP.toString().c_str());
}
Ticker lookup;
lookup.attach(5, [lookup]() {
IPAddress resolvedIP;
const char* host = "raspberrypi.local";
if (!WiFi.hostByName(host, resolvedIP)) {
Serial.print(F("(Ticker) Host lookup failed for "));
Serial.println(host);
} else {
Serial.print(F("(Ticker) Host: "));
Serial.print(host);
Serial.print(", IP: ");
Serial.println(resolvedIP.toString().c_str());
}
});
while (true) {
yield();
}
}
Debug Messages
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
SDK:2.2.1(cfd48f3)/Core:2.5.2=20502000/lwIP:STABLE-2_1_2_RELEASE/glue:1.1-7-g82abda3/BearSSL:a143020
wifi evt: 2
scandone
Waiting for connection..scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 7
cnt
connected with Xxxxxxxx, channel 8
dhcp client start...
wifi evt: 0
....ip:192.xxx.xxx.155,mask:255.255.255.0,gw:192.xxx.xxx.1
wifi evt: 3
Connected.
DNS #1: 1.1.1.1, DNS #2: 1.0.0.1
[hostByName] request IP for: raspberrypi.local
[hostByName] Host: raspberrypi.local IP: 192.xxx.xxx.131
(Loop) Host: raspberrypi.local, IP: 192.xxx.xxx.131
[hostByName] request IP for: raspberrypi.local
[hostByName] Host: raspberrypi.local IP: 192.xxx.xxx.131
(Ticker) Host: raspberrypi.local, IP: 192.xxx.xxx.131
pm open,type:2 0
[hostByName] request IP for: raspberrypi.local
[hostByName] Host: raspberrypi.local lookup error: -5!
(Ticker) Host lookup failed for raspberrypi.local
[hostByName] request IP for: raspberrypi.local
[hostByName] Host: raspberrypi.local IP: 192.xxx.xxx.131
(Ticker) Host: raspberrypi.local, IP: 192.xxx.xxx.131
[hostByName] request IP for: raspberrypi.local
[hostByName] Host: raspberrypi.local lookup error: -5!
(Ticker) Host lookup failed for raspberrypi.local
The cadence demonstrated here continues forever.
Metadata
Metadata
Assignees
Labels
No labels