wiced_hostname_lookup() returning wrong IP address when called twice

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaGr_2160016
Level 4
Level 4
First like received First like given
Every once in a while the second call to wiced_hostname_lookup() in sequence below returns the same IP address of the first call:

    WPRINT_APP_INFO(("Resolving IP address of Cometa server

" ));

    wiced_hostname_lookup("service.cometa.io", &ip_address, 15000);

    WPRINT_APP_INFO(("Cometa is at %u.%u.%u.%u

", (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 24),

                                                  (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 16),

                                                  (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 8),

                                                  (uint8_t)(GET_IPV4_ADDRESS(ip_address) >> 0) ) );

    #define APP_SERVER "www.cloudfridge.io"

    WPRINT_APP_INFO( ( "Resolving IP address of Application server %s

", APP_SERVER));

    result = wiced_hostname_lookup(APP_SERVER, &app_ip_address, 15000);

if (result != WICED_SUCCESS) {

       WPRINT_APP_INFO(("Error in DNS lookup for App server.

"));

       return;

      }

    WPRINT_APP_INFO( ( "App server is at %u.%u.%u.%u

", (uint8_t)(GET_IPV4_ADDRESS(app_ip_address) >> 24),

                                                  (uint8_t)(GET_IPV4_ADDRESS(app_ip_address) >> 16),

                                                  (uint8_t)(GET_IPV4_ADDRESS(app_ip_address) >> 8),

                                                  (uint8_t)(GET_IPV4_ADDRESS(app_ip_address) >> 0)));
0 Likes
3 Replies
MaGr_2160016
Level 4
Level 4
First like received First like given

It is an issue in 2.4. In general I find wiced_hostname_lookup() very unreliable.

0 Likes

Some more comments:

Part of this may be because the lookup() function sends a UDP request to all the registered DNS servers, and then waits for the remaining time (derived from the timeout passed to lookup()), for a reply. So, there is actually no retries happening.

0 Likes

This explains the behavior I am seeing. It may be worthwhile documenting.

In general, I cannot rely on the lookup() function. I wonder if you can provide any other insights.

0 Likes