HiveMQ Cloud credentials for MQTT over TLS

edouardreg
Posts: 3
Joined: Wed Apr 15, 2020 9:37 am

HiveMQ Cloud credentials for MQTT over TLS

Postby edouardreg » Mon Jun 28, 2021 2:44 pm

Hello,

I'm trying to connect my esp32 as mqtt client to HiveMQ Cloud. This one use TLS over 8883 and username and password credentials.

I tried the PPPOS client and with the eclipse : "mqtt://mqtt.eclipseprojects.io" it's OK.

The problem is that when I want to change it to use : "mqtts://9c2cf507f4604f8eb8db547c2fc2ee1c.s1.eu.hivemq.cloud", I don't see how configure credential ans so the connection to the broker is failed...

Is anybody had use this cloud broker and can share a working exemple or explain hox setting credential in esp-idf ?

franzhoepfinger
Posts: 21
Joined: Wed Mar 04, 2020 7:14 pm

Re: HiveMQ Cloud credentials for MQTT over TLS

Postby franzhoepfinger » Wed Jul 28, 2021 3:50 pm

mqtt://username:password@mqtt.eclipseprojects.io:1884 MQTT over TCP, port 1884, with username and password ?

like described here ?
https://docs.espressif.com/projects/esp ... /mqtt.html

franzhoepfinger
Posts: 21
Joined: Wed Mar 04, 2020 7:14 pm

Re: HiveMQ Cloud credentials for MQTT over TLS

Postby franzhoepfinger » Wed Jul 28, 2021 4:18 pm

for me this worked:

mqtts:///username:password@xxxxxxxx.s2.eu.hivemq.cloud:8883

on this Example:
https://github.com/espressif/esp-idf/tr ... s/mqtt/ssl

certificate for Eclipse and hive is same.

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: HiveMQ Cloud credentials for MQTT over TLS

Postby Jimis1 » Wed May 03, 2023 7:02 am

Hi,

I use ESP32 ESP-IDF example (https://github.com/espressif/esp-idf/bl ... app_main.c) to try connect to HiveMQ cloud but I get the error shown in the attachment

I have tested my CA certification file, username, password and client ID by successfully connecting via "MQTT explorer" application.

The url (mqtts://xxxxxxxx.s2.eu.hivemq.cloud:8883) doesn't contain username and password since I realized I could add them (code snippet shown below).

Code: Select all

    const esp_mqtt_client_config_t mqtt_cfg = {
        .broker = {
            .address.uri = CONFIG_BROKER_URI,
            .verification.certificate = (const char *)mqtt_eclipseprojects_io_pem_start
        },
        .credentials ={               
            .username= "my_username",
            .client_id= "ESP32_95989e",  // << you can ommit this line. client ID is constructed and sent automatically
            .authentication.password = "my_password"          
        }
    };
Certification file taken from here https://community.hivemq.com/t/frequent ... stions/514

Any ideas what could be wrong ?
Attachments
4b85cf58c9e81db3f524f9af1324901f1bec2f34.png
4b85cf58c9e81db3f524f9af1324901f1bec2f34.png (8.36 KiB) Viewed 3299 times

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: HiveMQ Cloud credentials for MQTT over TLS

Postby Jimis1 » Mon May 08, 2023 6:30 am

Found the problem.Stupid mistake. I had copy-pasted the same url twice in the appropriate field in menu config but couldn’t see it because the field is too small. I realized it when I moused over the uri variable.

Who is online

Users browsing this forum: ESP_Sprite and 143 guests