mDNS errors with "udp_join_multigrup failed!"

DavidDPD
Posts: 11
Joined: Thu Aug 06, 2015 8:54 am

mDNS errors with "udp_join_multigrup failed!"

Postby DavidDPD » Thu Aug 06, 2015 10:59 am

I've followed the SDK docs exactly for setting up mDNS, but I'm always getting :

Code: Select all

udp_join_multigrup failed!


I validate that the station is connected and has a validate IP before issuing the mdns setup.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: mDNS errors with "udp_join_multigrup failed!"

Postby ESP_Faye » Fri Aug 07, 2015 7:25 pm

Hi,

Could you provide the captured packets for debugging ?

Could you provide your test code, we will have a try.

Thanks for your interest in Espressif Systems and ESP8266 !

DavidDPD
Posts: 11
Joined: Thu Aug 06, 2015 8:54 am

Re: mDNS errors with "udp_join_multigrup failed!"

Postby DavidDPD » Mon Aug 10, 2015 1:30 pm

Espressif_Faye wrote:Hi,

Could you provide the captured packets for debugging ?

Could you provide your test code, we will have a try.

Thanks for your interest in Espressif Systems and ESP8266 !



I was ripping down the code to give you a smaller snippet, and in the process, I've found the issue. I am also using the NTP code by Richard Burton at https://github.com/raburton/esp8266/tree/master/ntp to grab the current unixtime.

This call is apparently polluting the UDP stack, something that the closed source mDNS SDK calls need. Simply calling mDNS before the NTP call fixes the issue. And for my application, this is perfectly acceptable.

However, this shouldn't be the case, so here is the the broken code, in case there is some clean up in the SDK to be done on the UDP side. It could be a usage bug with the NTP client, however it's pretty much following the suggested and sample code in the SDK docs.

I have not done a packet capture, but here is very reproducible code, with ifdef broken and unbroken examples with the NTP code. I have it up over at github.

https://github.com/daviddpd/dpd8266/tree/master/mdns

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: mDNS errors with "udp_join_multigrup failed!"

Postby ESP_Faye » Tue Aug 11, 2015 2:45 pm

Hi,

The "struct ip_info ipconfig;" in function "startup" is a local variable.

Code: Select all

static void CP_ICACHE_FLASH_ATTR
startup()
{
   uint32 t;
   uint32_t status;
   char buffer[128] = {0};
   struct ip_info ipconfig;
... ...
}

DavidDPD
Posts: 11
Joined: Thu Aug 06, 2015 8:54 am

Re: mDNS errors with "udp_join_multigrup failed!"

Postby DavidDPD » Fri Aug 21, 2015 2:08 pm

Ah ... yes that fixes it.

To expand on it a bit, the startup code does not do wifi_get_ip_info() it populate the 'struct ip_info ipconfig' before the mDNS init.

So, the IP Address in the in 'struct mdns_info *info ' ... initialized later :

Code: Select all

      
      struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
      info->ipAddr = ipconfig.ip.addr; //ESP8266 station IP


is likely null, or worse undefined. Thus creating the error. startup() is called multiple as part of the os_timer boottimer - however, when removing the ntp call to test, wifi_get_ip_info() and the initialization of the struct mdns_info, are done in the same loop, so the local struct had the info, verse when waiting for the time to get set, multiple calls of startup() were needed, resulting in struct ip_info n to be un-initialized.

Who is online

Users browsing this forum: No registered users and 51 guests