Description
Basic Infos
Mac OS 10.11.5
Hardware
Hardware: ESP-12E
Core Version: 2.2.0
Description
mDNS library fails to find DNS-SD services on the network, other than those which it creates. If I load this sketch onto several ESP modules, they all find each other's advertised service. I've picked through the library and am not quite sure what's going on - it seems to me like the library might be creating & looking for non-standard DNS-SD service records, but I have been unable to find out how.
I uncommented the debugs in the mDNS library for the debug output below, as well as enabling Debug level "ALL" in the Arduino IDE. The sketch I'm loading is just the example sketch with MDNS.queryService() looking for various services. The one included below (ipp) is a printer sharing advertisement.
Bonjour Browser shows 4 different services (all of which show "can't resolve link-local name", but do show titles, ip+port v4 & v6, and text records):
- _ipps._tcp. (my printer)
- _afpovertcp._tcp. (apple file sharing)
- _ipp._tcp. (also my printer)
- _smb._tcp. (also file sharing - Samba)
Although finding a printer or whatever is trivial, I would love to use this to find a computer on the network (with a dynamic IP) running an OTA server. The library is obviously finding SOMETHING, I think it's either just throwing errors when it shouldn't, or looking for the wrong service record structure or something...
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 160Mhz & 80Mhz (same behavior with both)
Flash Mode: qio
Flash Frequency: 40Mhz & 80Mhz
Upload Using: SERIAL
Reset Method: ck
Sketch
ESP8266 mDNS-SD responder and query sample
This is an example of announcing and finding services.
Instructions:
- Update WiFi SSID and password as necessary.
- Flash the sketch to two ESP8266 boards
- The last one powered on should now find the other.
*/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
const char* ssid = "<my network SSID>";
const char* password = "<my network password>";
char hostString[16] = {0};
void setup() {
Serial.begin(115200);
delay(100);
Serial.println("\r\nsetup()");
sprintf(hostString, "ESP_%06X", ESP.getChipId());
Serial.print("Hostname: ");
Serial.println(hostString);
WiFi.hostname(hostString);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(250);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (!MDNS.begin(hostString)) {
Serial.println("Error setting up MDNS responder!");
}
Serial.println("mDNS responder started");
MDNS.addService("esp", "tcp", 8080); // Announce esp tcp service on port 8080
Serial.println("Sending mDNS query");
int n = MDNS.queryService("ipp", "tcp"); // Send out query for esp tcp services
Serial.println("mDNS query done");
if (n == 0) {
Serial.println("no services found");
}
else {
Serial.print(n);
Serial.println(" service(s) found");
for (int i = 0; i < n; ++i) {
// Print details for each service found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(MDNS.hostname(i));
Serial.print(" (");
Serial.print(MDNS.IP(i));
Serial.print(":");
Serial.print(MDNS.port(i));
Serial.println(")");
}
}
Serial.println();
Serial.println("loop() next");
}
void loop() {
// put your main code here, to run repeatedly:
MDNS.update(); // I added this but it has the same behaviour with or without
}
Debug Messages
I've seen a few different patterns (I think the first one is more accurate, the second or something similar seems to happen if I switch networks after the sketch has started). Also not sure why it keeps showing airport, the router used for the below output is an older D-Link (although I've had the same result with at least 3 different routers).
These tests are all done with a single active ESP8266 module.
Connected to <my network>
IP address: 192.168.8.199
mDNS responder started
Sending mDNS query
queryService ipp tcp
Waiting for answers..
Reading answers RX: REQ, ID:0, Q:0, A:1, NS:0, ADD:7
Expected a packet with 4 answers, returning
ERR_NO_SERVICE: airport
mDNS query done
no services found
loop() next
pm open,type:2 0
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 47
Reading answers RX: REQ, ID:0, Q:0, A:1, NS:0, ADD:0
Not expecting any answers right now, returning
:urn 47
Reading answers RX: REQ, ID:0, Q:0, A:1, NS:0, ADD:0
Not expecting any answers right now, returning
Second Style:
Connected to <my network>
IP address: 192.168.8.199
mDNS responder started
Sending mDNS query
queryService ipp tcp
Waiting for answers..
mDNS query done
no services found
loop() next
pm open,type:2 0
:urn 240
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:0
Not expecting any answers right now, returning
:urn 400
:urd 39, 400, 13
ERR_NO_HOST: Samsung M2835 @ <my computer name>
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 400
:urd 39, 400, 13
ERR_NO_HOST: Samsung M2835 @ <my computer name>
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 538
:urd 8, 538, 13
:urd 4, 538, 22
:urd 5, 538, 27
ERR_NO_SERVICE: airport
:urn 400
:urd 39, 400, 13
ERR_NO_HOST: Samsung M2835 @ <my computer name>
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 1451
Reading answers RX: REQ, ID:0, Q:0, A:18, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 380
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 1451
Reading answers RX: REQ, ID:0, Q:0, A:18, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 380
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 156
Reading answers RX: REQ, ID:0, Q:0, A:5, NS:0, ADD:0
Not expecting any answers right now, returning
:urn 1451
Reading answers RX: REQ, ID:0, Q:0, A:18, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 380
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 1451
Reading answers RX: REQ, ID:0, Q:0, A:18, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 380
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 670
:urd 8, 670, 13
:urd 4, 670, 22
:urd 5, 670, 27
ERR_NO_SERVICE: airport
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 37
:urd 8, 37, 13
:urd 4, 37, 22
:urd 5, 37, 27
ERR_NO_SERVICE: arduino
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 53
:urd 13, 53, 13
ERR_NO_HOST: 192-168-8-198
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 47
Reading answers RX: REQ, ID:0, Q:0, A:1, NS:0, ADD:0
Not expecting any answers right now, returning
:urn 47
Reading answers RX: REQ, ID:0, Q:0, A:1, NS:0, ADD:0
Not expecting any answers right now, returning
:urn 515
:urd 8, 515, 13
:urd 4, 515, 22
:urd 5, 515, 27
ERR_NO_SERVICE: airport
:urn 400
:urd 39, 400, 13
ERR_NO_HOST: Samsung M2835 @ <my computer name>
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 400
:urd 39, 400, 13
ERR_NO_HOST: Samsung M2835 @ <my computer name>
hostname: esp_e1a6cf
instance: ESP_E1A6CF
:urn 833
:urd 8, 833, 13
:urd 4, 833, 22
:urd 5, 833, 27
ERR_NO_SERVICE: airport
:urn 1451
Reading answers RX: REQ, ID:0, Q:0, A:18, NS:0, ADD:1
Not expecting any answers right now, returning
:urn 380
Reading answers RX: REQ, ID:0, Q:0, A:9, NS:0, ADD:1
Not expecting any answers right now, returning
// stops here (forever?), unless there is a change in services
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.