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

Parents
  • Hi.

    The mqtt_socket library merges all errors on connecting to -111 (connection refused).

    However, the reason for your failure to connect might be other things than just some issue with the certificates.

    Can you add a print inside the "if block" ncs/nrf/subsys/net/lib/mqtt_socket/mqtt.c:322 that prints the value of err_code?

    AWS (which nRF Cloud) is built upon uses load balancing, so the IP address of the endpoint you are looking for might change without warning.

    Best regards,

    Didrik

  • Further debugging shows that the call in nrf91_sockets.c inside nrf91_socket_offload_connect() hangs for quite a few seconds and then returns the timeout error when calling nrf_connect().

    I'm not able to debug this further as it then goes into debugging assembly code...

    Do you know how to increase timeout values for the modem establishing the TLS 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

Reply
  • 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

Children
Related