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

Failed to connect to cloud, error -7

Hi!

Running the Asset-Tracker routine will fail to connect to the cloud(ncs1.3.0). The serial port displays an error say Failed to connect to cloud, error -7.

[13:59:54.870]←◆[00:01:13.570,983]  <dbg> nrf_cloud_transport.nct_mqtt_evt_handler: MQTT_EVT_CONNACK: result -111 
[00:01:13.580,261]  <dbg> nrf_cloud.nfsm_set_current_state_and_notify: state: 1 
[00:01:13.587,921]  <dbg> nrf_cloud.api_event_handler: NRF_CLOUD_EVT_ERROR: -111 
[00:01:13.595,672]  <inf> asset_tracker: CLOUD_EVT_ERROR 

[13:59:55.399]←◆[00:01:14.101,501]  <dbg> nrf_cloud.nrf_cloud_run: Socket error: POLLNVAL 
[00:01:14.108,642]  <dbg> nrf_cloud.nrf_cloud_run: The cloud socket was unexpectedly closed. 
[00:01:14.117,401]  <inf> asset_tracker: CLOUD_EVT_DISCONNECTED: 2 
[00:01:14.123,931]  <inf> asset_tracker: Cloud connection closed. 
[00:01:14.130,371]  <inf> asset_tracker: This can occur during initial nRF Cloud provisioning. 
[00:01:14.139,312]  <inf> asset_tracker: Attempting reconnect in 10 seconds... 
[00:01:14.146,881]  <dbg> nrf_cloud_transport.nct_disconnect: nct_disconnect 

[14:00:05.444]←◆[00:01:24.146,942]  <inf> asset_tracker: Connecting to cloud, attempt 2 of 8 
[00:01:24.154,388]  <inf> asset_tracker: Cloud connection request sent. 
[00:01:24.161,346]  <inf> asset_tracker: Connection response timeout is set to 30 seconds. 
[00:01:24.169,982]  <inf> asset_tracker: CLOUD_EVT_CONNECTING 

[14:00:06.527]←◆[00:01:25.228,881]  <dbg> nrf_cloud_transport.nct_connect: IPv4 address: 3.223.232.82 

[14:00:35.146]←◆+CSC
[14:00:35.178]←◆ON: 0
[00:01:53.849,548]  <dbg> lte_lc.at_handler: +CSCON notification 

[14:02:51.144]←◆[00:0
[14:02:51.170]←◆4:09.852,294]  <dbg> nrf_cloud_transport.nct_mqtt_connect: mqtt_connect failed -22 
[00:04:09.860,687]  <inf> asset_tracker: CLOUD_EVT_CONNECTING 
[00:04:09.866,790] <err> asset_tracker: Failed to connect to cloud, error -7 
[00:04:09.874,511] <err> asset_tracker: Ensure device has a valid private key 
[00:04:09.882,324] <err> asset_tracker: Device will reboot in 300 seconds 
[00:04:09.889,801] <err> asset_tracker: LTE link disconnect 

Error -7 is Invalid private key.

/**@brief Cloud connect results. */
enum cloud_connect_result {
	CLOUD_CONNECT_RES_SUCCESS = 0,

	CLOUD_CONNECT_RES_ERR_NOT_INITD = -1,
	CLOUD_CONNECT_RES_ERR_INVALID_PARAM = -2,
	CLOUD_CONNECT_RES_ERR_NETWORK = -3,
	CLOUD_CONNECT_RES_ERR_BACKEND = -4,
	CLOUD_CONNECT_RES_ERR_MISC = -5,
	CLOUD_CONNECT_RES_ERR_NO_MEM = -6,
	/* Invalid private key */
	CLOUD_CONNECT_RES_ERR_PRV_KEY = -7,
	/* Invalid CA or client cert */
	CLOUD_CONNECT_RES_ERR_CERT = -8,
	/* Other cert issue */
	CLOUD_CONNECT_RES_ERR_CERT_MISC = -9,
	/* Timeout, SIM card may be out of data */
	CLOUD_CONNECT_RES_ERR_TIMEOUT_NO_DATA = -10,
	CLOUD_CONNECT_RES_ERR_ALREADY_CONNECTED = -11,
};

It worked fine yesterday, but it's been running today with this error. 

I tried the NCS1.2.0 routine and it worked fine

  • Hi

    Probably a stupid question, but have you ensured that your private key is valid? Did you make any changes from yesterday before running into this error? The error "-7" should only be caused by your private key not being valid.

    Best regards,

    Simon

  • Hi

    I didn't make any changes to the example.I just modified prj.conf to support NB-iot.

    After constant testing, found that sometimes connected and sometimes not connected.This is also the case with NCS1.2.0.

  • Hello,

    I am sorry for the late reply, but due to low staffing in R&D and Tech.support, we are having trouble answering all incoming questions. Unfortunately, I don't know how to approach the issue that you describe. I will try to reach out for the right people tomorrow. 

    Best regards,

    Edvin

  • Hello,

    So the issue is that the key is invalid. 

    Have you tried to follow this guide:
    https://devzone.nordicsemi.com/nordic/cellular-iot-guides/b/getting-started-cellular/posts/nrf-cloud-certificate-update

    Perhaps you have invalid certificates, which could lead to error -7. 

    Does the issue occur even if you revert the changes to the prj.conf, and disable NB-IoT?

    Best regards,

    Edvin

  • Hi,

    I have renewed my certificate again.

    I'm in Shenzhen, China. Only NB-IOT is supported here. Here is my prj.conf.

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    CONFIG_LOG=y
    CONFIG_LOG_IMMEDIATE=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    
    # LTE link control
    CONFIG_POWER_OPTIMIZATION_ENABLE=n
    CONFIG_LTE_LINK_CONTROL=y
    #CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y
    
    CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y
    CONFIG_LTE_LEGACY_PCO_MODE=y
    CONFIG_LTE_PSM_REQ_RPTAU="00000110"
    CONFIG_LTE_PSM_REQ_RAT="00000010"
    
    # Modem info
    CONFIG_MODEM_INFO=y
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    CONFIG_BSD_LIBRARY_TRACE_ENABLED=n
    
    # nRF Cloud
    CONFIG_CLOUD_API=y
    CONFIG_NRF_CLOUD=y
    CONFIG_NRF_CLOUD_LOG_LEVEL_DBG=y
    CONFIG_NRF_CLOUD_AGPS=y
    CONFIG_NRF_CLOUD_CONNECTION_POLL_THREAD=y
    CONFIG_NRF_CLOUD_NONBLOCKING_SEND=y
    # Needed for the cloud codec
    CONFIG_CJSON_LIB=y
    # Shorter to prevent NAT timeouts
    CONFIG_MQTT_KEEPALIVE=120
    # Don't resubscribe to topics if broker remembers them
    CONFIG_CLOUD_PERSISTENT_SESSIONS=y
    
    # Sensors
    CONFIG_ACCEL_USE_SIM=y
    CONFIG_TEMP_USE_SIM=y
    CONFIG_CLOUD_BUTTON=n
    
    # GPS
    CONFIG_NRF9160_GPS=y
    # CONFIG_GPS_USE_SIM=y
    CONFIG_NRF9160_GPS_LOG_LEVEL_DBG=y
    CONFIG_GPS_USE_EXTERNAL=y
    CONFIG_GPS_DEV_NAME="NRF9160_GPS"
    CONFIG_GPS_CONTROL_PSM_ENABLE_ON_START=y
    
    CONFIG_GPS_CONTROL_FIRST_FIX_CHECK_DELAY=10
    CONFIG_GPS_CONTROL_FIX_CHECK_INTERVAL=30
    CONFIG_GPS_CONTROL_FIX_TRY_TIME=360
    CONFIG_GPS_CONTROL_PSM_DISABLE_ON_STOP=n
    
    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=y
    CONFIG_DK_LIBRARY_INVERT_LEDS=n
    
    # Console
    CONFIG_CONSOLE_SUBSYS=y
    CONFIG_CONSOLE_HANDLER=y
    CONFIG_CONSOLE_GETCHAR=y
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_HW_STACK_PROTECTION=y
    
    # MCUBOOT
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    
    # Flash
    CONFIG_FLASH=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # AWS FOTA
    CONFIG_AWS_FOTA=y
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_AWS_FOTA_LOG_LEVEL_DBG=y
    CONFIG_AWS_JOBS_LOG_LEVEL_DBG=y
    CONFIG_DFU_TARGET=y
    
    # Download client (needed by AWS FOTA)
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    
    # Fatal error
    CONFIG_RESET_ON_FATAL_ERROR=n
    CONFIG_WATCHDOG=y
    

    This error just happened again. Especially in the afternoon, it happens a lot and the connection is slow. It's about morning in the Nordic. Is there something wrong with the cloud?

Related