cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT connect fails to connect to IoT Hub. Generic error of 0x10005 NXD_MQTT_CONNECT_FAILURE

MD'Si.1
Associate III

I am using an STM32F429 Nucleo 144 and the Ethernet interface to run an Azure Iot client.

Using STM32Cube IDE version 1.8.0

NetxDuo versios 6.1.7

Nx_SNTP_Client Sample project

I have combined this example with NetxDuo's sample_azure_iot_embedded_sdk_with_retry.c Once the IP address and SNTP server is connected (time is sync'd) I start the Azure client thread.

My code is not able to successfully connect to the iOT hub. The call to mqtt_client_secure_connect() eventually returns the generic NXD_MQTT_CONNECT_FAILURE (i.e. 0x00010005 from file nxd_mqtt_client.h). The response code is generic and does not help with further debugging. Is there some additional logging or method to debug this.

Here is a snippet from the console output

Nx_SNTP_Client application started..
STM32 IpAddress: ***.***.***.***
SNTP client connected to NTP server : < ca.pool.ntp.org > 
 
SNTP update :
Mar 24, 2022 16:34:9.699 UTC 
.....
24-03-2022 / 16:34:09
24-03-2022 / 16:34:09
[INFO] Azure IoT Security Module has been enabled, status=0
IoTHub Host Name: xxxxxxxx.azure-devices.net; Device ID: stm32F429xxxxx.
24-03-2022 / 16:34:09
24-03-2022 / 16:37:41
....
24-03-2022 / 16:37:51
24-03-2022 / 16:37:52
24-03-2022 / 16:37:52
24-03-2022 / 16:37:52
24-03-2022 / 16:37:52
[ERROR] IoTHub client connect fail: MQTT CONNECT FAIL status: 65541
Disconnected from IoTHub!: error code = 0x00010005
Failed on nx_azure_iot_hub_client_connect!
reconnecting iothub, after backoff
24-03-2022 / 16:39:54
24-03-2022 / 16:39:54

1 ACCEPTED SOLUTION

Accepted Solutions
MD'Si.1
Associate III

I have opened a ticket with Netxduo team on Github https://github.com/azure-rtos/netxduo/issues/86 if someone has run into a similar issue.

View solution in original post

5 REPLIES 5
MD'Si.1
Associate III

The function nx_secure_tls_session_start (line 3939, file nxd_mqtt_client.c) returns a value of 56. I cannot find a #define for what this value means.

Guillaume K
ST Employee

hello,

so it's a TLS problem ?

did you initialize correctly the TLS part ?

see Microsoft Azure IoT example at https://github.com/azure-rtos/netxduo/blob/1eee883def078a91b8cd19159d1796e3a8862814/addons/azure_iot/samples/sample_azure_iot_embedded_sdk.c#L182

in particular, they have additional root certificates root_ca_cert_2 and root_ca_cert_3 to be added to the TLS config.

Guillaume K
ST Employee

if return value 56 is decimal, then in nx_api.h there is

#define NX_NOT_CONNECTED                          0x38 // 56 in decimal

MD'Si.1
Associate III

@Guillaume K​ Thank you for your suggestion from the netxduo Github repo. I already found that example and adjusted my root certificates to use the latest ones.

The return code of 56 is decimal. I was hoping the connect routine would provide an error indication like Host unreachable, TLS handshake failure, etc.

MD'Si.1
Associate III

I have opened a ticket with Netxduo team on Github https://github.com/azure-rtos/netxduo/issues/86 if someone has run into a similar issue.