Asset Tracker MQTT Error -116

Hi,

I have tried to follow the steps outlined in https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/networking/azure_iot_hub.html to connect my Thingy 91 to Azure. I am seeing the below message in LTE Link Monitor:

mqtt_helper: mqtt_connect, error: -116

What does error -116 mean in the context of Azure IoT hub connection?

  • Details about the setup:

    1. Root CA, sub-ordinate CA and device certificate were created using the tutorial available on https://learn.microsoft.com/en-us/azure/iot-hub/tutorial-x509-test-certs#tabpanel_1_linux
    2. Root and sub-ordinate certificates were combined into a single file and uploaded to Azure IoT Hub
    3. Azure IoT Hub Root Certificate was upgraded to DigiCert Global G2 root
    4. Device private key generated in step 2 was decrypted to remove the password
    5. DigiCert Global G2 root certificate, device certificate and decrypted private key generated in step 4 were uploaded to Thingy91 using AT Client and LTE Link Monitor
    6. Asset Tracker v2's overlay_azure.conf was edited to the below:
      #
      # Copyright (c) 2021 Nordic Semiconductor ASA
      #
      # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
      #
      
      CONFIG_AZURE_IOT_HUB=y
      CONFIG_AZURE_IOT_HUB_DPS=n
      CONFIG_AZURE_IOT_HUB_AUTO_DEVICE_TWIN_REQUEST=n
      # Increase the number of maximum message properties that can be parsed by the Azure IoT Hub library.
      # Needed to be able to parse P-GPS responses.
      CONFIG_AZURE_IOT_HUB_MSG_PROPERTY_RECV_MAX_COUNT=4
      
      # Azure IoT Hub options that must be configured in order to establish a connection.
      CONFIG_AZURE_IOT_HUB_HOSTNAME="{iot-hub-name}.azure-devices.net"
      CONFIG_AZURE_IOT_HUB_DEVICE_ID="{common name for device certificate}"
      CONFIG_MQTT_HELPER_SEC_TAG=16842753
      # MQTT Transport library
      # Maximum specified MQTT keepalive timeout for Azure IoT Hub is 1177 seconds.
      CONFIG_MQTT_KEEPALIVE=1177
      
    7. Asset tracker was built and uploaded to the device
    8. Below log was observed:
              ABADAAAGAAAaBb9icmMA/7ke
      *** Booting Zephyr OS build v3.2.99-ncs2 ***
      [00:00:01.502,960] <inf> app_event_manager: APP_EVT_START
      [00:00:01.528,594] <inf> app_event_manager: DATA_EVT_CONFIG_INIT
      [00:00:01.529,296] <inf> app_event_manager: MODEM_EVT_INITIALIZED
      [00:00:01.545,715] <inf> azure_fota: Current firmware version: 0.0.0-development
      [00:00:01.591,552] <inf> app_event_manager: MODEM_EVT_LTE_CONNECTING
      %CESQ: 46,2,7,1
      +CEREG: 2,"2014","07F03F0B",7
      %CESQ: 50,2,20,2
      +CSCON: 1
      %CESQ: 49,2,15,2
      %CESQ: 49,2,20,2
      [00:00:02.780,181] <inf> app_event_manager: MODEM_EVT_LTE_CELL_UPDATE
      +CGEV: ME PDN ACT 0,0
      +CNEC_ESM: 50,0
      %MDMEV: SEARCH STATUS 2
      +CEREG: 5,"2014","07F03F0B",7,,,"00001010","11000010"
      %XTIME: "04","32509220807304","00"
      [00:00:06.961,486] <inf> app_event_manager: MODEM_EVT_LTE_CONNECTED
      [00:00:06.962,585] <inf> app_event_manager: CLOUD_EVT_CONNECTING
      [00:00:07.075,988] <inf> app_event_manager: MODEM_EVT_LTE_PSM_UPDATE
      [00:00:07.076,660] <inf> app_event_manager: DATA_EVT_DATE_TIME_OBTAINED
      %CESQ: 50,2,13,1
      %CESQ: 50,2,21,3
      +CSCON: 0
      %CESQ: 51,2,15,2
      %CESQ: 50,2,22,3
      %CESQ: 50,2,17,2
      %CESQ: 51,2,22,3
      %CESQ: 51,2,16,2
      %CESQ: 51,2,21,3
      %CESQ: 255,0,255,0
      %CESQ: 49,2,18,2
      %MDMEV: SEARCH STATUS 2
      +CSCON: 1
      [00:02:57.772,857] <err> mqtt_helper: mqtt_connect, error: -116
      [00:02:57.772,888] <err> azure_iot_hub: mqtt_helper_connect failed, error: -116
      [00:02:57.772,888] <err> azure_iot_hub_integration: azure_iot_hub_connect, error: -116
      %CESQ: 49,2,23,3
      %CESQ: 50,2,17,2
      %CESQ: 50,2,23,3
      +CSCON: 0
      +CSCON: 1
      %CESQ: 50,2,17,2
      %CESQ: 50,2,22,3
      [00:03:29.773,071] <inf> app_event_manager: CLOUD_EVT_CONNECTION_TIMEOUT
      [00:03:29.773,651] <inf> app_event_manager: CLOUD_EVT_CONNECTING
      %CESQ: 50,2,14,2
      +CSCON: 0
      %CESQ: 50,2,25,3
      %CESQ: 50,2,19,2
      %CESQ: 255,0,255,0
      %CESQ: 48,2,12,1
      %MDMEV: SEARCH STATUS 2
      %CESQ: 51,2,23,3
      +CSCON: 1
      %CESQ: 50,2,18,2
      [00:06:20.892,700] <err> mqtt_helper: mqtt_connect, error: -116
      [00:06:20.892,730] <err> azure_iot_hub: mqtt_helper_connect failed, error: -116
      [00:06:20.892,730] <err> azure_iot_hub_integration: azure_iot_hub_connect, error: -116
      %CESQ: 50,2,13,1
      %CESQ: 50,2,19,2
      %CESQ: 51,2,14,2
      %CESQ: 51,2,19,2
      +CSCON: 0
      +CSCON: 1
      %CESQ: 51,2,14,2
      %CESQ: 50,2,20,2
      %CESQ: 51,2,14,2
      %CESQ: 51,2,20,2
      %CESQ: 51,2,15,2
      %CESQ: 51,2,21,3
      %CESQ: 51,2,16,2
      +CSCON: 0
      %CESQ: 50,2,23,3
      %CESQ: 50,2,18,2
      %CESQ: 50,2,12,1
      %CESQ: 50,2,17,2
      %CESQ: 255,0,255,0
      %CESQ: 46,2,10,1
      %MDMEV: SEARCH STATUS 2
      +CSCON: 1
      [00:07:24.892,913] <inf> app_event_manager: CLOUD_EVT_CONNECTION_TIMEOUT
      [00:07:24.893,493] <inf> app_event_manager: CLOUD_EVT_CONNECTING
      %CESQ: 50,2,15,2
      %CESQ: 49,2,21,3
      %CESQ: 50,2,15,2
      +CSCON: 0
      %CESQ: 50,2,10,1
      %CESQ: 51,2,16,2
      %CESQ: 50,2,11,1
      %CESQ: 255,0,255,0
      

    * I'm not using DPS

    * SDK version is 2.3.0

  • Tried the same configuration with azure_iot_hub, and experienced the same result. prj.conf, modem trace and serial log attached. Password to the attached file is my email address.

    pc-nrfconnect-tracecollector-preview.7z

    Also tested the SIM card and DNS lookup by uploading https-client sample:

  • I have also confirmed that Thingy91 can communicate to the IoT endpoint on port 443 by modifying https_client sample's source code:

  • Hey,

    It looks like a certificate/key issue, as the device attempts to use PSK for TLS, which does not work. You should ensure that the device certificate and key are written to the correct entries in The Certificate manager, according to https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/networking/azure_iot_hub.html#azure-iot-hub-flash-certs.

    You could also delete the PSK entries on the relevant sec tag.

  • Hi,

    Thanks for the reply. This difference in the timezone is killing me Sweat smile

    Does this mean we can use PSK on Azure IoT hub instead a certificate? That would certainly make life much easier for development / testing at least.

Related