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

cloud_connect failed: -111

Hi, the thread at https://devzone.nordicsemi.com/f/nordic-q-a/48859/nrf9160-dk-connecting-problems-with-nrf-cloud/211627 has been very useful for me to get past several problems getting the asset tracker example to work. I connect successfully to a NB-IoT network here in Norway now, thanks to (as explained in the linked thread) setting modem mode to NB-IoT, using legacy PCO mode and using a static IP address since DNS is not supported.

Finally, the problem I am left with is "cloud_connect failed: -111". I had high hopes that a certificate update (devzone.nordicsemi.com/.../nrf-cloud-certificate-update) would solve this, but after successfully updating my certificates the same problem still persists. 

I have a nRF9160 DK v 0.8.5, with modem FW updated. I can successfully connect to the network using the at_client sample. Since the SIM included with the dev. kit only supports LTE-M1 (no coverage where I am located), I am using a SIM card from com4.no to connect to NB-IoT.

Here is my output from the terminal:

***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-2647-gd6e67554cfeb *****


[00:00:00.378,173] 
[0m<dbg> nrf9160_gps.init: MAGPIO set: AT%XMAGPIO=1,0,0,1,1,1574,1577[0m


Asset tracker started


[00:00:00.389,282] 
[0m<dbg> nrf_cloud_transport.nct_client_id_get: client_id = nrf-352656100223414[0m


[00:00:00.398,498] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: shadow_base_topic: $aws/things/nrf-352656100223414/shadow[0m


[00:00:00.410,156] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: accepted_topic: nrf-352656100223414/shadow/get/accepted[0m


[00:00:00.421,661] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: rejected_topic: $aws/things/nrf-352656100223414/shadow/get/rejected[0m


[00:00:00.434,204] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: update_delta_topic: $aws/things/nrf-352656100223414/shadow/update/delta[0m


[00:00:00.447,082] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: update_topic: $aws/things/nrf-352656100223414/shadow/update[0m


[00:00:00.458,923] 
[0m<dbg> nrf_cloud_transport.nct_topics_populate: shadow_get_topic: $aws/things/nrf-352656100223414/shadow/get[0m


Connecting to LTE network. This may take several minutes.


[00:00:00.477,172] 
[0m<inf> lte_lc: Using legacy LTE PCO mode...[0m


[00:00:00.483,428] 
[0m<dbg> lte_lc.w_lte_lc_connect: Network mode: AT%XSYSTEMMODE=0,1,1,0[0m


[00:00:04.653,717] 
[0m<dbg> lte_lc.at_handler: recv: +CEREG: 2,"0CEB","0202791C",9,0,0,"11100000","11100000"[0m

[00:00:04.664,123] 
[0m<dbg> lte_lc.parse_nw_reg_status: Network registration status: 2[0m


[00:00:05.574,218] 
[0m<dbg> lte_lc.at_handler: recv: +CEREG: 1,"0CEB","0202791C",9,,,"11100000","11100000"[0m


[00:00:05.584,472] 
[0m<dbg> lte_lc.parse_nw_reg_status: Network registration status: 1[0m


Connected to LTE network


[00:00:05.595,123] 
[0m<dbg> nrf_cloud_transport.nct_connect: IPv4 Address 52.54.149.10[0m


cloud_connect failed: -111


LTE link disconnect


Shutdown modem


***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-2647-gd6e67554cfeb *****


...

Any other suggestions would be greatly appreciated.

Kind regards,

Terje

  • Hi,

    The IP address was refreshed (using https://whatismyipaddress.com/hostname-ip) just before retrying.

    I searched the settings for "timeout" and increased NET_CONFIG_INIT_TIMEOUT to 60 seconds, and increased NET_SOCKETS_CONNECT_TIMEOUT to 60000 ms.

    The results are still the same. Timeout after around 15-20 seconds after calling nrf_connect() from within nrf91_socket_offload_connect() inside the file nrf91_sockets.c.

    Do you know how I can increase the timeout for TLS handshake/connection?

  • I do not think it would help to increase the timeout.

    Can you try to run the mqtt_simple* and ntp samples?

    Both use DNS by default, without a simple option to disable it, but it should not be too hard to convert them. I've added the code used by the nrf_cloud library when a static IP is used.

    If you are not able to get the mqtt_simple or ntp samples to work either, a modem trace might help us find the error.

    #if defined(CONFIG_NRF_CLOUD_STATIC_IPV4)
    /* Partly copy/paste from zephyr/subsys/net/ip/utils.c
     * Cannot be used when BSD library selects NET_RAW_MODE
     */
    int af_inet_addr_pton(sa_family_t family, const char *src, void *dst)
    {
    	if (family == AF_INET) {
    		struct in_addr *addr = (struct in_addr *)dst;
    		size_t i, len;
    
    		len = strlen(src);
    		for (i = 0; i < len; i++) {
    			if (!(src[i] >= '0' && src[i] <= '9') &&
    				src[i] != '.') {
    				return -EINVAL;
    			}
    		}
    
    		(void)memset(addr, 0, sizeof(struct in_addr));
    
    		for (i = 0; i < sizeof(struct in_addr); i++) {
    			char *endptr;
    
    			addr->s4_addr[i] = strtol(src, &endptr, 10);
    
    			src = ++endptr;
    		}
    	} else {
    		return -ENOTSUP;
    	}
    
    	return 0;
    }
    
    int nct_connect(void)
    {
    	int err;
    
    	struct sockaddr_in *broker =
    		((struct sockaddr_in *)&nct.broker);
    
    	af_inet_addr_pton(AF_INET, CONFIG_NRF_CLOUD_STATIC_IPV4_ADDR,
    		&broker->sin_addr);
    	broker->sin_family = AF_INET;
    	broker->sin_port = htons(NRF_CLOUD_PORT);
    
    	LOG_DBG("IPv4 Address %s", CONFIG_NRF_CLOUD_STATIC_IPV4_ADDR);
    	err = nct_mqtt_connect();
    
    	return err;
    }

    * If you are using v1.0.0, note that the MQTT broker has changed hostname from iot.eclipse.org to mqtt.eclipse.org

  • After struggling quite a bit to get network traffic going for NB-IoT using other simpler examples as you suggested, I've contacted our SIM card provider (Com4 in Norway). They are telling me I need to change the APN from the default "com4" to "iot.com4.net". I am however having trouble doing this (APN change won't be saved), so I found it best to create a new thread to ask for help regarding changing APN:

    https://devzone.nordicsemi.com/f/nordic-q-a/53364/unable-to-change-apn

  • Success! I Network traffic now works, and the asset tracker example (tested on the master branch) now works.

    The problem turned out to be the network provider not having configured my SIM card/subscription to allow it to use NB-IoT. And also not telling me about this the first time I contacted them...

    After this configuration change with the network provider, the correct APN is automatically used for context CID 0.

    The problem was confising me because I registered and received an IP address on the network. So it was far from obvious that the problem was with the cellular subscription configuration.

    DNS now also works. So please note: DNS problems can be because network traffic does not work in general.

    Thank you for your help.

    Kind regards,

    Terje

  • Hi.

    Great to hear that everything now works.

    If you have any further questions, feel free to open a new ticket.

    Have a great day!

    Didrik

Related