How to connect device using AT-Commands(Simcom) into HiveMQ Cloud

This is my script

AT+CMQTTSTART
+CMQTTSTART: 0

OK
AT+CMQTTACCQ=0,“Test1”,1
OK
AT+CMQTTCONNECT=0,“tcp://xxxx.s1.eu.hivemq.cloud:8883”,60,1,“User Name”,“Password”
OK

+CMQTTCONNECT: 0,31

Its return 31 means connection refused: not authorized
What should I do?

Hi Thitiwat,

Thank you for your interest in MQTT and HiveMQ!

You are connecting to the port 8883 that listening for TLS encrypted connection. In case if your device requires server CA, please check out our Frequently Asked Questions – it contains instructions to get the server certificate.

Kind regards,
Dasha from HiveMQ team

Does this issue solved?I am also facing the same issue.

Me too. did you solve it

Hello @caotheanh ,

Thank you for following up here!

We would be happy to provide additional assistance in completing connectivity to HiveMQ Cloud. With that in mind, we would require some additional details about the exact errors you are receiving, or connection methods currently used with your AT implementation.

It is worth mentioning that when connecting to a HiveMQ Cloud broker, TLS is required, along with TLS-SNI. This ensures that TLS connections proceed successfully, and are not rejected during TLS negotiation.

It is also worth mentioning that some IoT hardware, utilizing AT commands, have limitations in place on the size of packets used for TLS negotiation, and this limitation can in some cases prevent TLS negotiation from completing successfully due to packet size. This is sometimes mutable with additional preparatory commands, and may be worth reviewing as well.

With that said, please let us know if you have success connecting with these adjustments, or if you are encountering further errors, please provide some additional context for the errors you are receiving, and we will be happy to assist!

Best,
Aaron from the HiveMQ Team