Page 1 of 1

HiveMQ Cloud credentials for MQTT over TLS

Posted: Mon Jun 28, 2021 2:44 pm
by edouardreg
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 ?

Re: HiveMQ Cloud credentials for MQTT over TLS

Posted: Wed Jul 28, 2021 3:50 pm
by franzhoepfinger
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

Re: HiveMQ Cloud credentials for MQTT over TLS

Posted: Wed Jul 28, 2021 4:18 pm
by franzhoepfinger
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.

Re: HiveMQ Cloud credentials for MQTT over TLS

Posted: Wed May 03, 2023 7:02 am
by Jimis1
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 ?

Re: HiveMQ Cloud credentials for MQTT over TLS

Posted: Mon May 08, 2023 6:30 am
by Jimis1
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.