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 Reply Children
No Data
Related