Failed to establish a connection with TLS/MQTTS broker using mqttclient
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am attempting to make an application utilizing OpenF1's MQTT stream but am having issues creating a connection. The following information is provided by the documentation:
Connection Details
- MQTT server: mqtt.openf1.org
- MQTT port (TLS/MQTTS): 8883
- Websockets URL (WSS for MQTT over Websockets): wss://mqtt.openf1.org:8084/mqtt
Authentication
Both MQTT and Websocket connections use the OAuth2 access token as the password for authentication. The username can typically be any non-empty string, or your registered email if preferred/required by your client library for token-based auth.
after receiving a token I am able to establish a connection on MQTTX with settings:
Host: mqtts:// mqtt.openf1.org
SSL/TLS : Yes
SSL Secure: No
Certificate: CA signed server certificate
However in MATLAB, all variations of the following line are met with error message "Failed to establish a connection with broker"
mqttClient = mqttclient("ssl://mqtt.openf1.org", Username="example@email.com", Password=token, Port=8883, CARootCertificate="mqtt.openf1.org.crt")
The certificate was downloaded via the method described in https://www.mathworks.com/matlabcentral/answers/1889632-how-to-download-root-certificate-for-use-with-industrial-communication-toolbox-mqtt-functions.This is my first time using MQTT, please help me identify my error or suggest troubleshooting steps.
0 comentarios
Respuestas (2)
Kautuk Raj
el 22 de Jul. de 2025
I was also seeing the same error in one of my workflows when trying to connect to a secure MQTT broker from MATLAB.
I found a discussion on a GitHub issue (https://github.com/eclipse-paho/paho.mqtt.c/issues/1385) which helped me resolve the issue, I will reproduce it below for your convenience.
You can resolve the issue by specifying the path after the port number in the URL in the following format:
protocol://hostname:port/path
instead of using protocol://hostname/path:port
0 comentarios
Govind KM
el 22 de Jul. de 2025
Editada: Govind KM
el 22 de Jul. de 2025
I was facing a similar error message when trying to connect an MQTT client over websockets in MATLAB R2024b, but was able to connect successfully in R2025a. If possible, I would recommend upgrading to the R2025a release and trying out the same workflow.
0 comentarios
Ver también
Categorías
Más información sobre MQTT Protocol Communication en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!