mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Sun Nov 24, 2019 4:17 pm

Hi,

The mDNS example in IDF V3.3 works fine for me, but v4.0 does not. I can ping the targets IP address, and pressing the BOOT button results in a list of mDNS devices on my network. What's not working is ping esp32-mdns.local. I can ping other .local devices on my network.

One big difference from v3.3 to v4.0 is the change to using esp_event_loop_create_default()

So I'm wondering where mdns_handle_system_event is called in the v4.0 example?

The IDF docs say applications are required to call it from the system event handler for normal operation of mDNS service. In looking at the IDF source I don't see where this happens.

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Mon Nov 25, 2019 12:52 am

It's not mentioned in the IDF docs, but mdns_handle_system_event is tagged as deprecated in mdns.h, so the default handler must handle mDNS somehow.

Still trying to figure out why mDNS is not working.

Code: Select all

esp_err_t mdns_handle_system_event(void *ctx, system_event_t *event) __attribute__((deprecated));

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby ESP_cermak » Mon Nov 25, 2019 8:58 am

Hi growver,

The mdns event handler is registered internally in mdns_init() here: https://github.com/espressif/esp-idf/bl ... ns.c#L4246.
There's no need to register them in a user code anymore, nor use the `mdns_handle_system_event()`

How does your mdns initialisation code look like? Is it the same as the mdns example code from v4.0 https://github.com/espressif/esp-idf/bl ... ple_main.c?

Thanks,
David

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Tue Nov 26, 2019 1:08 am

Unfortunately, the ESP-IDF mDNS example itself is not working for me either. Reporting of other mDNS devices works (i.e. when the button is pressed), but I can't ping esp32-mdns.local just the IP address.
I tried the example in ESP-IDF v3.3 and had no issues, so still stumped about what's wrong now that I'm working with v4.0. Wireshark shows the mDNS client request from the ping, but it's completely ignored by unmodified ESP32 mDNS example. I'll dig deeper, but was hoping it was something obvious.

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Wed Nov 27, 2019 2:33 am

I still haven't been able to successfully run ping esp32-mdns.local using ESP-IDF V4. I've been digging into mdns code by adding ESP_LOGI statements. I can see that the ESP32 mdns example is seeing the multicast mDNS packet, the host name matches successfully, and _mdns_upd_pcb_write() completes, sending 92 UDP bytes is response (from mdns_networking.c)

However, I still can't see the response in wireshark and the ping fails.

Can someone confirm that pinging the mDNS example in V4 works? (only v3.3 works for me).

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby WiFive » Thu Nov 28, 2019 4:46 am

It works in 4.1

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Sun Dec 01, 2019 2:31 pm

Thanks WiFive,

Moving my project to IDF V4.1-dev got mDNS working. I don't understand why but moving forward again.

ESP_cermak
Posts: 69
Joined: Thu Nov 01, 2018 8:32 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby ESP_cermak » Mon Dec 02, 2019 10:58 am

There might be a related bugfix, not included in v4.0-beta2, but already on the release branch (https://github.com/espressif/esp-idf/co ... 3652efa30c)
Could you please check if that resolves the ping issue? (either using release/v4.0 branch or picking that commit to your IDF version)

growver
Posts: 8
Joined: Thu Nov 21, 2019 1:34 am

Re: mDNS ping example not working in ESP-IDF v4.0 Beta 0.2

Postby growver » Wed Dec 04, 2019 2:31 am

cermak,

I can confirm that your changes fixed the issue I was seeing. To be sure I also went back to V4.0 Beta 2 to re-confirm that the mDNS example was not working.

Thanks for the fix!

Who is online

Users browsing this forum: Eshwar487, ESP_Roland and 105 guests