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

https_client returning "getaddrinfo() failed, err 9"

I am based in Hong Kong. I purchased NB-IoT sim card with "Three". 

When using LTE Link Monitor, (with at_client) I can connect to the NB_IoT network, as Three support told me they can see my sim connected.

When I try https_client sample, I get "getaddrinfo() failed, err 9"

I changed prj.conf to cope with NB-IoT, rather than the standard LTE-M at boot:

CONFIG_BSD_LIBRARY=y
CONFIG_BSD_LIBRARY_SYS_INIT=n

CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_NATIVE=n

CONFIG_HEAP_MEM_POOL_SIZE=4096
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_MODEM_KEY_MGMT=y
CONFIG_LTE_LINK_CONTROL=y

CONFIG_LTE_NETWORK_MODE_LTE_M=n
CONFIG_LTE_NETWORK_MODE_NBIOT=y

CONFIG_LTE_AUTO_INIT_AND_CONNECT=y


Do you know how to solve this?

Thanks in advance.

Parents Reply Children
  • Trying mqtt_simple.

    I added the last 3 lines to prj.conf

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    
    # Networking
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    
    # AT Host
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y
    
    # MQTT
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=n
    
    # Appliaction
    #CONFIG_MQTT_PUB_TOPIC="/my/publish/topic"
    #CONFIG_MQTT_SUB_TOPIC="/my/subscribe/topic"
    #CONFIG_MQTT_CLIENT_ID="my-client-id"
    #CONFIG_MQTT_BROKER_HOSTNAME="mqtt.eclipse.org"
    #CONFIG_MQTT_BROKER_PORT=1883
    
    # Main thread
    CONFIG_MAIN_STACK_SIZE=4096
    
    CONFIG_HEAP_MEM_POOL_SIZE=2048
    
    CONFIG_LTE_NETWORK_MODE_LTE_M=n
    CONFIG_LTE_NETWORK_MODE_NBIOT=y
    
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=y

    Then I compiled and flashed through command line.

    And with PuTTY, I got this message:

    *** Booting Zephyr OS build v2.1.99-ncs1  ***
    +CEREG: 2,"0BF4","099E5765",9,0,0,"11100000","11100000"
    +CEREG: 1,"0BF4","099E5765",9,,,"11100000","11100000"
    The MQTT simple sample started
    ERROR: getaddrinfo failed 22
    ERROR: mqtt_connect -47

    Does it clarify?

  • Hi,

     

    Thank you for the logs and testing this.

    Unfortunately, this shows that your local carrier does not provide DNS.

     

    When testing examples, you can manually resolve the hostname, for instance:

    mqtt.eclipse.org resolves to "137.135.83.217" when I ping it at my end, then you can set this as the prj.conf::CONFIG_MQTT_BROKER_HOSTNAME="137.135.83.217"

     

    Alternative can be to manually set the DNS, as a user has done in this post:

    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

Related