mqttclient unable to establish a connection with broker

7 visualizzazioni (ultimi 30 giorni)
Hello, I am trying to connect to a HiveMQ broker with the mqttclient function. I am able to connect to the broker with other apps such as MQTTX or MQTT explorer, so I know the credentials are correct.
mqttClient = mqttclient("ssl://4d96d3eaeb474fd6a5121398823c69f7.s1.eu.hivemq.cloud", ...
"Port", 8883, ...
"Username", "matlabhelptest", ...
"Password", "testTEST1111");
The error I get is: Failed to establish a connection with broker "ssl://4d96d3eaeb474fd6a5121398823c69f7.s1.eu.hivemq.cloud".
Are there any known issues with mqttclient not establishing connections with secure brokers? I am able to connect to unsecure brokers such as mqtt://broker.hivemq.com with the port = 1883.
Thanks so much for your help on this topic.

Risposte (1)

Swastik Sarkar
Swastik Sarkar il 17 Giu 2025
Since it has been confirmed that the broker connection works via MQTT Explorer, it can be assumed that the host is reachable and the credentials are valid. Given that the issue arises specifically when connecting to secure brokers, it is advisable to ensure the use of a valid CA root certificate in conjunction with the mqttclient command.
Further information on configuring the MQTT client in MATLAB can be found in the official documentation:
Additionally, a detailed MATLAB Central Answer provides guidance on obtaining a root certificate for use with api.thingspeak.com. This approach can be extended to work with the broker currently being connected to:
I hope this helps resolve the issue with connecting to the secure MQTT broker.

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Tag

Prodotti


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by