This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf9160 getaddrinfo() return error -11

Hello,

it's been a couple of days that i have a problem with NRF9160DK.

The problem is related to function getaddrinfo() that is now permanently returning -11, whatever i do. The code i'm using as a base (and, i repeat, that worked without any changes up to about 1 week ago) is the http example. This code snippet is where the problem happens:

void http_motherRegister(u32_t mbAddress, u8_t batt_status)
{
    struct sockaddr_in local_addr;
    struct addrinfo *res;
    int send_data_len;
    int num_bytes;
    int mtu_size = MAX_MTU_SIZE;
    char message_buf[MAX_MESS_SIZE];
    char send_buf[SEND_BUF_SIZE];
    
    local_addr.sin_family = AF_INET;
    local_addr.sin_port = htons(0);
    local_addr.sin_addr.s_addr = 0;

    printk("\n\r\n\rHTTP motherRegister routine started\n");

    int err = getaddrinfo(HTTP_HOST, NULL, NULL, &res);

    printk("getaddrinfo err: %d\n", err);
    //THE BOARD CRASHES HERE
    ((struct sockaddr_in *)res->ai_addr)->sin_port = htons(HTTP_PORT);

This is what my serial print is:

*** Booting Zephyr OS build v2.1.99-ncs1-4-gc025ef3dd566  ***
+CEREG: 2,"FFFE","FFFFFFFF",7,0,0,"11100000","11100000"
+CEREG: 2,"80F3","04987148",9,0,0,"11100000","11100000"
+CEREG: 4,"80F3","04987148",9,0,15,"11100000","11100000"
+CEREG: 4,"FFFE","FFFFFFFF",9,0,15,"11100000","11100000"
+CEREG: 2,"90EA","010F0971",9,0,15,"11100000","11100000"
+CEREG: 2,"90EA","010F0971",9,0,13,"11100000","11100000"
+CEREG: 2,"FFFE","FFFFFFFF",9,0,13,"11100000","11100000"
+CEREG: 2,"7B88","04DCDD88",9,0,13,"11100000","11100000"
+CEREG: 5,"7B88","04DCDD88",9,,,"11100000","11100000"
LAP Motherboard State machine initializing...

SM State: INIT

SM State: SERVER_REG

HTTP motherRegister routine started
getaddrinfo err: -11

*** Booting Zephyr OS build v2.1.99-ncs1-4-gc025ef3dd566  ***
Flash regionDomainPermissions
00 0x00000 0x08000 Securerwxl

I really don't know what could be the cause. From what i understand from the serial print the board connects (+CEREG: 5) and the software boots normally (execute a state machine i coded), but when getaddrinfo() is called for DNS resolution it returns error and reboots the board.

Some info on my hardware:

- NRF9160DK (last firmware)

- nrf9160 modem firmware 1.1.1 (and now 1.2.0, same behaviour)

- SIM IBasis (still 90% of data plan available)

Things i tried:

- Changed the HTTP_HOST define from my host to "ptsv2.com" to make a test --> still not working

- Updated the modem firmware to version 1.2.0 (from 1.1.1) --> still not working

Parents
  • No,

    exactly the same problem occurs. This is the serial output of the mqtt_simple example:

    *** Booting Zephyr OS build v2.1.99-ncs1-4-gc025ef3dd566  ***
    The MQTT simple sample started
    LTE Link Connecting ...
    +CEREG: 2,"FFFE","FFFFFFFF",7,0,0,"11100000","11100000"
    +CEREG: 0,"FFFE","FFFFFFFF",7,0,0,"11100000","11100000"
    +CEREG: 2,"80F3","04987148",9,0,0,"11100000","11100000"
    +CEREG: 4,"80F3","04987148",9,0,15,"11100000","11100000"
    +CEREG: 4,"FFFE","FFFFFFFF",9,0,15,"11100000","11100000"
    +CEREG: 2,"7B88","04DCDD86",9,0,15,"11100000","11100000"
    +CEREG: 5,"7B88","04DCDD86",9,,,"11100000","11100000"
    LTE Link Connected!
    ERROR: getaddrinfo failed -11
    ERROR: mqtt_connect -47

    Waiting for your feedback

    Frax

Reply
  • No,

    exactly the same problem occurs. This is the serial output of the mqtt_simple example:

    *** Booting Zephyr OS build v2.1.99-ncs1-4-gc025ef3dd566  ***
    The MQTT simple sample started
    LTE Link Connecting ...
    +CEREG: 2,"FFFE","FFFFFFFF",7,0,0,"11100000","11100000"
    +CEREG: 0,"FFFE","FFFFFFFF",7,0,0,"11100000","11100000"
    +CEREG: 2,"80F3","04987148",9,0,0,"11100000","11100000"
    +CEREG: 4,"80F3","04987148",9,0,15,"11100000","11100000"
    +CEREG: 4,"FFFE","FFFFFFFF",9,0,15,"11100000","11100000"
    +CEREG: 2,"7B88","04DCDD86",9,0,15,"11100000","11100000"
    +CEREG: 5,"7B88","04DCDD86",9,,,"11100000","11100000"
    LTE Link Connected!
    ERROR: getaddrinfo failed -11
    ERROR: mqtt_connect -47

    Waiting for your feedback

    Frax

Children
  • Hi,

     

    This is very common error to see if your local carrier does not provide DNS servers. You could try setting it manually, as shown here, and see if that works?

    https://devzone.nordicsemi.com/f/nordic-q-a/50029/nrf9160-modem-firmware-v1-0-0-setting-custom-dns-server/235419#235419

    Kind regards,

    Håkon

  • Hi, i'm going to try as soon as possible (within tomorrow probably) and provide you a feedback. By the way, i want to underline that the same code never had this problems in the last two months. I always have been able to communicate with my (or any other) server. It's just the last two days i'm not able anymore.

    Could it be a temporary network provider issue?

  • Hi,

     

    frax84 said:
    Could it be a temporary network provider issue?

    It could be, but what has changed since the last time it was working?

    Now you are on NB1, were you always on NB1, or has it recently done the switch from LTE M1 to NB1?

     

    Is there anything out-of-the-ordinary (or different from a previous working situation) if you run at_client? Is it still connecting to the same provider?

     

    Kind regards,

    Håkon

  • It could be, but what has changed since the last time it was working?

    Absolutely nothing, at least from the development code point of view. I even used a working code backup from my github to be sure to have not messed up my code, but nothing changed. From the network side, unfortunately i didn't saved the details about the network, so i'm not sure if i'm connecting on the same network as the previous 2 (working) months. Of course this could be a good point. If i'm connected on a different network this one could not provide DNS service. I'll take note of the full CEREG string from now on.

    Now you are on NB1, were you always on NB1, or has it recently done the switch from LTE M1 to NB1?

    I'm in Rome, Italy. As far as i know in Italy we have no national LTE-M network deployed. The biggest providers (Vodafone and TIM [Telecom Italia Mobile]) deployed national NB-IoT coverage, so yes, i have always been on NB1 (9 on CEREG).

    This is very common error to see if your local carrier does not provide DNS servers. You could try setting it manually, as shown here, and see if that works?

    I'm happy to say that, with manual DNS setup, it works!

    For people who could occur in the same problem i did, this is the function i used:

    static void modem_configure(void)
    {
      if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
        /* Do nothing, modem is already turned on
        * and connected.
        */
      } else {
        //Set manually DNS server
        struct nrf_in_addr dns;
        dns.s_addr = 134744072; // Google DNS, 8.8.8.8 in u32 rapresentation
        int err = nrf_setdnsaddr(2, &dns);
        if (err ==0) {
          printk("DNS correctly set\n");
        } else {
          printk("Error %d, DNS not set\n", err);
        }
        
        //Init network connection
        printk("LTE Link Connecting ...\n");
        err = lte_lc_init_and_connect();
        __ASSERT(err == 0, "LTE link could not be established.");
        printk("LTE Link Connected!\n");
        }
    }

    Please remember to set properly .config file

    Thanks for the nice and fast support!

    Frax

  • Please remember to set properly .config file

    Can you please explain what you mean @frax84? I have used this code but I am still getting a "error -11" on getaddrinfo

Related