Skip to content

ESP32 MDNS.queryService returns only one instance per service. #8917

@JesFo

Description

@JesFo

I've tried getting a list of service instances with this code:
numServices = MDNS.queryService("_revpipyload", "tcp");
When using a service browser, I see both of my instances like so:
cap0

Both the MQTT and NodeRED instances are visible.
However, no matter what I do, the line above always only returns "1". Also, whenever i try to look up the entries with MDNS.hostname(X). Only index 0 returns a value.
I've tried this with different ESP32 devkits, Including but not limited to: wESP32, Olimex POE ISO, ESP32_CAM, ESP32 Devkit V4, and so on...
Each one so far has the same problem.

I've also tried changing the service names and protocols using other Avahi/Bonjour capable devices, but I get the same results.
I use the ESP32 Arduino core version 2.0.8 with PlatformIO.

And my code's setup looks like this:

void setup()
{
  Serial.begin(115200); 
  ETH.begin(0, -1, 16, 17, ETH_PHY_RTL8201);
  MDNS.begin("ControlUnit");
  MDNS.addService("revpipyload", "tcp", 123);
  numServices = MDNS.queryService("_revpipyload", "tcp");
  Serial.print("Number of services found: ");
  Serial.println(numServices);
  for (int i = 0; i < numServices; i=i+1) {

    Serial.println("---------------");
      
    Serial.print("Hostname: ");
    Serial.println(MDNS.hostname(i));

    Serial.print("IP address: ");
    Serial.println(MDNS.IP(i));

    Serial.print("Port: ");
    Serial.println(MDNS.port(i));

    Serial.println("---------------");
  }
}

Even if i try manually to print out MDNS.hostname(1) I get nothing.
Is this considered a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions