nRF9160DK: MQTT Connection Error - Azure IoT Hub

Hi, 

I have been using the nRF9160-DK sample code to connect my dk to my hosted Azure IoT Hub. I have followed the documentation for creating the certificates for both the CA Cert to put on my IoT Hub and as well the client-side certificate. I used the AT Client to turn off the modem before updating the certificates as told to do so in the documentation and as well testing the certificates using the sample verification and data from that simulation was able to send. However, when trying to do so from the device failed. I am not sure whether this is a certificate issue or a code issue. Please advise. I am not using DPS fyi

I have been troubleshooting for a couple of days now and I can't seem to understand where this issue is coming from. Below is the logging information for what is happening to my device. 

Thanks in advance! 

/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Logging.jpg_2D00_640x480.jpg

*** Booting Zephyr OS build v3.2.99-ncs2 ***
[00:00:00.531,005] <inf> azure_iot_hub_sample: Azure IoT Hub sample started
[00:00:00.531,127] <inf> azure_iot_hub_sample: Connecting to LTE network
+CEREG: 2,"3BC5","03090216",7
+CSCON: 1
[00:00:16.855,957] <inf> azure_iot_hub_sample: LTE cell changed: Cell ID: 50922006, Tracking area: 15301
[00:00:17.616,760] <inf> azure_iot_hub_sample: RRC mode: Connected
+CEREG: 5,"3BC5","03090216",7,,,"00001010","11000001"
[00:00:20.076,843] <inf> azure_iot_hub_sample: Network registration status: Connected - roaming
[00:00:20.076,995] <inf> azure_iot_hub_sample: Connected to LTE network
[00:00:20.077,056] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_UNINIT --> STATE_DISCONNECTED
[00:00:20.077,056] <inf> azure_iot_hub_sample: Azure IoT Hub library initialized
[00:00:20.077,117] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_DISCONNECTED --> STATE_CONNECTING
[00:00:20.077,148] <inf> azure_iot_hub_sample: AZURE_IOT_HUB_EVT_CONNECTING
[00:00:20.077,239] <dbg> azure_iot_hub: azure_iot_hub_connect: User name: HubIoTSZGP.azure-devices.net/iotdemodevice/?api-version=2020-09-30&DeviceClientType=azsdk-c%2F1.4.0-beta.2
[00:00:20.077,270] <dbg> azure_iot_hub: azure_iot_hub_connect: User name buffer size is 128, actual user name size is: 106
[00:00:20.078,521] <inf> azure_iot_hub_sample: PSM parameter update: TAU: 1152000, Active time: 20
[00:00:20.577,545] <err> mqtt_helper: mqtt_connect, error: -111
[00:00:20.577,545] <err> azure_iot_hub: mqtt_helper_connect failed, error: -111
[00:00:20.577,606] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_CONNECTING --> STATE_DISCONNECTED
[00:00:20.577,636] <err> azure_iot_hub_sample: azure_iot_hub_connect failed: -111
+CSCON: 0
[00:00:27.182,922] <inf> azure_iot_hub_sample: RRC mode: Idle

Parents
  • **Update It seems like I have fixed the certificate issue. I am now getting this in my logs however and I still don't see the data in my Azure IoT Hub. 

    *** Booting Zephyr OS build v3.2.99-ncs2 ***
    [00:00:00.522,186] <inf> azure_iot_hub_sample: Azure IoT Hub sample started
    [00:00:00.522,308] <inf> azure_iot_hub_sample: Connecting to LTE network
    +CEREG: 2,"3BEB","01610D04",7
    +CSCON: 1
    +CEREG: 2,"3BEB","01610D04",7,0,11
    [00:00:20.043,518] <inf> azure_iot_hub_sample: LTE cell changed: Cell ID: 23137540, Tracking area: 15339
    [00:00:20.311,553] <inf> azure_iot_hub_sample: RRC mode: Connected
    +CSCON: 0
    +CEREG: 2,"874A","0B78580F",7
    [00:00:21.653,564] <inf> azure_iot_hub_sample: RRC mode: Idle
    [00:00:22.121,490] <inf> azure_iot_hub_sample: LTE cell changed: Cell ID: 192436239, Tracking area: 34634
    +CSCON: 1
    +CEREG: 2,"874A","0B78580F",7,0,11
    [00:00:22.696,289] <inf> azure_iot_hub_sample: RRC mode: Connected
    +CSCON: 0
    +CEREG: 2,"874A","0B78580F",7
    +CSCON: 1
    [00:00:24.092,559] <inf> azure_iot_hub_sample: RRC mode: Idle
    [00:00:24.284,332] <inf> azure_iot_hub_sample: RRC mode: Connected
    +CEREG: 5,"874A","0B78580F",7,,,"00001010","11000001"
    [00:00:28.785,552] <inf> azure_iot_hub_sample: Network registration status: Connected - roaming
    [00:00:28.785,736] <inf> azure_iot_hub_sample: Connected to LTE network
    [00:00:28.785,766] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_UNINIT --> STATE_DISCONNECTED
    [00:00:28.785,797] <inf> azure_iot_hub_sample: Azure IoT Hub library initialized
    [00:00:28.785,858] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_DISCONNECTED --> STATE_CONNECTING
    [00:00:28.785,858] <inf> azure_iot_hub_sample: AZURE_IOT_HUB_EVT_CONNECTING
    [00:00:28.786,071] <dbg> azure_iot_hub: azure_iot_hub_connect: User name: HubIoTSZGP.azure-devices.net/iotdemodevice/?api-version=2020-09-30&DeviceClientType=azsdk-c%2F1.4.0-beta.2
    [00:00:28.786,071] <dbg> azure_iot_hub: azure_iot_hub_connect: User name buffer size is 128, actual user name size is: 106
    [00:00:28.787,170] <inf> azure_iot_hub_sample: PSM parameter update: TAU: 1152000, Active time: 20
    [00:00:32.657,501] <inf> azure_iot_hub_sample: Connection request sent to IoT Hub
    [00:00:32.897,613] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_CONNECTING --> STATE_CONNECTED
    [00:00:32.897,613] <dbg> azure_iot_hub: on_connack: MQTT mqtt_client connected
    [00:00:32.898,712] <dbg> azure_iot_hub: topic_subscribe: Successfully subscribed to default topics
    [00:00:32.898,712] <inf> azure_iot_hub_sample: AZURE_IOT_HUB_EVT_CONNECTED
    [00:00:33.050,872] <inf> azure_iot_hub_sample: AZURE_IOT_HUB_EVT_READY
    [00:00:33.050,994] <dbg> azure_iot_hub: request_id_create_and_get: Request ID not specified, using "330"
    [00:00:33.051,269] <inf> azure_iot_hub_sample: Sending event:{"temperature":25.1,"timestamp":33051}
    [00:00:33.051,757] <dbg> azure_iot_hub: device_twin_request: Device twin requested
    [00:00:33.052,307] <inf> azure_iot_hub_sample: Event was successfully sent
    [00:00:33.052,337] <inf> azure_iot_hub_sample: Next event will be sent in 20 seconds
    [00:00:33.187,774] <wrn> azure_iot_hub: DISCONNECT, result: -128
    [00:00:33.187,835] <dbg> azure_iot_hub: iot_hub_state_set: State transition: STATE_CONNECTED --> STATE_DISCONNECTED
    [00:00:33.187,866] <inf> azure_iot_hub_sample: AZURE_IOT_HUB_EVT_DISCONNECTED
    [00:00:33.187,896] <err> mqtt_helper: Cloud MQTT input error: -128
    +CSCON: 0
    [00:00:38.900,634] <inf> azure_iot_hub_sample: RRC mode: Idle

  • Hey Sam,

    I'm experiencing the same issue you had in the first log. I set up the certificate exactly as told and it doesn't work with the same error code. What did you do to fix the issue if you remember?

Reply Children
Related