ADL
ADL

Reputation: 89

Connecting ESP32 IDF MQTT5 Example to HIVEHQ

I am using the IDF MQTT5 example project, and have built it unmodified and can connect to Mosquito

I (47716) mqtt5_example: Other event id:7 I (47726) main_task: Returned from app_main() I (49036) mqtt5_example: MQTT_EVENT_CONNECTED

I now want to change the broker to HIVEHQ but am battling to get the HIVHQ URI accepted. I have opened an account at HIVEHQ and can connect and use it successfully with a Python Paho test app I wrote using MQTT5 and TLS so I know the broker side is good.

I started by changing the line:

.broker.address.uri = CONFIG_BROKER_URL,

to my hive URI

.broker.address.uri = "d72b0b51da08402e86d06db5db25f244.s1.eu.hivemq.cloud",

It seems the URI cannot be passed in this format and my logs show: [Codebox=text file=Untitled.txt]E (27296) mqtt_client: Error parse uri = d72b0b51da08402e86d06db5db25f244.s1.eu.hivemq.cloud[/Codebox]

or this format

.broker.address.uri = "mqtt://d72b0b51da08402e86d06db5db25f244.s1.eu.hivemq.cloud",

my logs: E (39766) esp-tls: [sock=54] select() timeout E (39766) transport_base: Failed to open a new connection: 32774 E (39766) mqtt_client: Error transport connect

So I tried commenting out

// .broker.address.uri = CONFIG_BROKER_URL,

and adding

.broker.address.hostname = "d72b0b51da08402e86d06db5db25f244.s1.eu.hivemq.cloud",
.broker.address.port = 8883,
.broker.address.transport = MQTT_TRANSPORT_OVER_TCP,

my logs: E (21096) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read(): EOF E (21096) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=128

So I went back to eclipse broker and tried:

.broker.address.uri = CONFIG_BROKER_URL,
.broker.address.port = 8883,
.broker.address.transport = MQTT_TRANSPORT_OVER_TCP, my logs: W (30676) mqtt_client: Transport config set, but overridden by scheme

from URI: transport = 1, uri scheme = mqtt E (30686) mqtt5_client: Client was not initialized

Can someone please help with a working solution for my HIVEHQ account

Thanks

Upvotes: 0

Views: 297

Answers (1)

ADL
ADL

Reputation: 89

I managed to get this going. Heres how for future reference for others: I went to the MQTT/SSL example first and followed the instructions without any modifications but could not get it to connect to the Mosquitto broker. It turns out the certificate in the example is the problem and I think may not be a root certificate. Anyway Mosquito didn't like it. I replace the project default CA certificate (mqtt_eclipseprojects_io.pem) contents with the Root CA certificate I got from: https://letsencrypt.org/certs/isrgrootx1.pem 1. I left the same certificate name (mqtt_eclipseprojects_io.pem) so I didn’t have to make any changes to the code. From this I could connect the MQTT/SSL project to the Mosquitto broker using SSL. I then returned to my MQTT5 project and added the certificate code etc from the MQTT SSL example. I added my login credentials ID and Password. And then everything worked.

Upvotes: 0

Related Questions