Azure IoT Middleware for Freertos - Failed to establish MQTT connection, error 0x00000006

leo lee 20 Reputation points
2024-04-16T02:46:24.3066667+00:00

log

I used the ESP32S3 for azure iot connection and according to the code I have done the following:

DPS:

prvConnectToServerWithBackoffRetries --> OK

AzureIoTProvisioningClient_Init --> OK

AzureIoTProvisioningClient_Register --> OK

AzureIoTProvisioningClient_GetDeviceAndHub --> OK

IoT Hub:

prvConnectToServerWithBackoffRetries --> OK

AzureIoTHubClient_OptionsInit --> OK

AzureIoTHubClient_Init --> OK

But it fails in the call to AzureIoTHubClient_Connect with the previous log messages. AzureIoTResult_t value is 1.

We also encountered the same problem, and then we updated the certificate and this problem still occurred:

E (28665) MQTT: Connection refused: not authorized.

E (28665) MQTT: CONNACK recv failed with status = MQTTServerRefused.

E (28675) MQTT: MQTT connection failed with status = MQTTServerRefused.

E (28685) AZ IOT: Failed to establish MQTT connection: Server=XXX.azure-devices.net, MQTT error=0x00000006.

In the same question, I saw that deleting the Module ID would allow me to connect to azure iot, but I tried to leave the MODULE ID unconfigured or leave it empty.

Can you please help me? Please help check it.

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
407 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,222 questions
{count} votes

Accepted answer
  1. AshokPeddakotla-MSFT 35,576 Reputation points
    2024-05-14T04:10:53.7433333+00:00

    leo lee I'm glad that your issue is resolved and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    Error Message:

    log

    I used the ESP32S3 for azure iot connection and according to the code I have done the following:

    DPS:

    prvConnectToServerWithBackoffRetries --> OK

    AzureIoTProvisioningClient_Init --> OK

    AzureIoTProvisioningClient_Register --> OK

    AzureIoTProvisioningClient_GetDeviceAndHub --> OK

    IoT Hub:

    prvConnectToServerWithBackoffRetries --> OK

    AzureIoTHubClient_OptionsInit --> OK

    AzureIoTHubClient_Init --> OK

    But it fails in the call to AzureIoTHubClient_Connect with the previous log messages. AzureIoTResult_t value is 1.

    We also encountered the same problem, and then we updated the certificate and this problem still occurred:

    E (28665) MQTT: Connection refused: not authorized.

    E (28665) MQTT: CONNACK recv failed with status = MQTTServerRefused.

    E (28675) MQTT: MQTT connection failed with status = MQTTServerRefused.

    E (28685) AZ IOT: Failed to establish MQTT connection: Server=XXX.azure-devices.net, MQTT error=0x00000006.

    In the same question, I saw that deleting the Module ID would allow me to connect to azure iot, but I tried to leave the MODULE ID unconfigured or leave it empty.

    Solution:

    Before, I used the routine of azure-iot-middleware-freertos for reference to Microsoft's official instructions, but it corresponds to ESPRESSIF ESP32-Azure IoT Kit, but I used the chip of esp32s3. Therefore, I cannot connect to azure iot hub. I have successfully connected to azure iot hub after converting the routine.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Andrew Thomas 6 Reputation points
    2024-10-09T19:38:19.3966667+00:00

    @leo Leo I am having the same problem, and has an esp32s3 too.

    Can you be more specific on your fix "I have successfully connected to azure iot hub after converting the routine."?


  2. leo lee 20 Reputation points
    2024-10-10T07:48:06.9033333+00:00

    Hellp,Andrew Thomas

    I am by switching cases compile directory: / iot - middleware - freertos - samples/demos/projects/ESPRESSIF/esp32. After filling in the certificate information, the compilation is used normally. If you have any questions, please keep asking.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.