Hello
I have the following code section made in Matlab app designer, trying to connect to HiveMQ Cloud without success, any suggestion?
% Connection between MATLAB & MQTT broker
brokerAddress = ‘tcp://eb8fd3d5e3b84571a38041117c1e666c.s1.eu.hivemq.cloud’;
port = 8883; % Secure MQTT port
I would like to offer a suggestion for your consideration. Kindly consider using tls instead of tcp, and please let us know if this adjustment proves beneficial for your situation.
In the event that this recommendation does not resolve your issue, could you please take a moment to share the specific documentation you have been following? It’s possible that there may be documentation specifying the appropriate prefix to use for secure connections, and this information could aid you in providing you with more targeted assistance.
Thank you for your time and cooperation. We’re here to help and look forward to resolving any challenges you may be facing.
Hi Dasha,
I just used the tls instead of tcp and didn’t worked. I got the following error:
Error using mqttclient
The value of ‘BrokerAddress’ is invalid. Invalid connection protocol. For secure
connection specify ssl:// or wss://. For nonsecure connection specify tcp:// or
mqtt:// or ws://.
% Connection between MATLAB & MQTT broker
brokerAddress = ‘tls://xxxxxxxxxxxxxxxxxxxxx.s1.eu.hivemq.cloud’;
port = 8883;
clientID = ‘76271ae1a3094a9999d06f8ee5148686’;
MQTTSignal = mqttclient(brokerAddress,‘Port’,port,‘ClientID’,clientID,‘Username’,‘DCM_user001’,‘Password’,‘DCm0t0r2024’);
% Publish topic using MQTT in MATLAB
Topic = “ESP32/data”;
write(MQTTSignal,Topic,jsonData);
Thank you for reaching out. I appreciate your prompt response. Use the ssl instead of tls as suggested. Let us know if this adjustment proves beneficial for your situation.
If you encounter any challenges or have further questions, feel free to reach out. We’re here to assist you.
I used both ssl and tls and wss and same error that cannot be connected; so I think that it needs a root certificate just like ESP32 (last example). But I’m not really sure about how to do that since I haven’t found any related information about it. If you could get some matlab example I’ll appreciate it.
Thx
What is matlab? If your device or library does not contain the Let’s Encrypt root certificate yet, you can download the root certificate here .
This will create a file called “isrgrootx1.pem”, which you can use as a “Server Certificate”.#
Thanks Dasha! I already made my code used this root certificate, and apparently it worked, nono error was displayed.
I just only need to find out if it is subscribing and publishing.
I’ll be in touch. Thx
Dasha,
It worked perfectly, but I wonder if you can help me now to solve why my ESP32 is not receiving this topic, could be because of the root certificate that is different?
Thank you for reaching out and providing details about the issue you’re experiencing.
The server root CA certificate is intended for connection purposes only and not for subscribing or publishing. If your client is successfully connected but facing issues with subscribing or publishing, it’s advisable to review the ACCESS CREDENTIALS.
To assist you further, please navigate to console.hivemq.cloud and access the “Access Management” section. Kindly take a screenshot of the entire page, including permissions and users. This will help us analyze the settings and identify any potential issues.
Thank you for reaching out. I appreciate your proactive approach in providing screenshots of your permissions settings. Based on the information you’ve shared, it seems that your permissions are configured correctly, allowing MQTT clients using DCM_user001 to publish and subscribe to any topic (filter #).
To assist you further, could you please share the full version of your code? Specifically, I would like to review the sections where your device subscribes to the topic and where it handles received messages. This will enable me to analyze the code more effectively and provide you with targeted assistance.
Looking forward to your response and working together to resolve any issues you may be encountering.