Hivemq mqtt_client: MQTT connect failed

I have implemented an esp32 project to connect to a the HiveMQ broker via MQTT. However I constantly receive the message:
mqtt_client: Connection refused, not authorized
mqtt_client: MQTT connect failed

I have set the CA certificate to ISGR Root X1 as it is instrcuted by the HiveMQ Team members in these posts:

I have also followed the example on

I m sending below my repo

Hi @misupora great to see you join. If you’re experimenting or just beginning with HiveMQ, feel free to share your thoughts and questions.

Typically users have this error when the IoT device does not support TLS-SNI (server name indication). Please verify your device as explained here:

Best,
Dasha from HiveMQ Team

Dear Dasha,

thank you for your response,
I have performed the test according to the tutorial you have sent and my results were

ACCEPT
Received Record
Header:
Version = TLS 1.2 (0x303)
Content Type = Handshake (22)
Length = 245
ClientHello, Length=241
client_version=0x303 (TLS 1.2)

and


extensions, length = 82
extension_type=server_name(0), length=22
0000 - 00 14 00 00 11 37 2e 74-63 70 2e 65 75 2e 6e   …7.tcp.eu.n
000f - 67 72 6f 6b 2e 69 6f                           grok.io

that means that my ESP32 support TLS-SNI

I have also followed the tutorial:

I constantly receive:

esp-tls: couldn’t get hostname for :xxxxx.s1.eu.hivemq.cloud: getaddrinfo() returns 202, addrinfo=0x0

my broker uri is:
“mqtts://xxxxxx.s1.eu.hivemq.cloud:8883”

Hi @misupora

Thank you for the detailed follow-up and for performing the TLS-SNI verification. It is great to see that your client supports TLS-SNI.

At this stage, it would be helpful to determine whether the issue is specific to resolving the hostname for your HiveMQ Cloud instance (xxxxxx.s1.eu.hivemq.cloud) or whether it is a more general DNS resolution issue on the device.

As a next step, could you please test the same client against another public MQTT broker, for example:

test.mosquitto.org:8883
(Server certificate: https://test.mosquitto.org/ssl/mosquitto.org.crt)

If your device is able to successfully resolve and connect to test.mosquitto.org but continues to fail with the HiveMQ Cloud hostname, this would indicate that the issue is related to the HiveMQ Cloud endpoint.
However, if the client is unable to resolve test.mosquitto.org as well, then the problem is likely related to your Wi-Fi network’s DNS configuration.

Please let us know the results of this test so we can assist you further.

Best regards,
Dasha from HiveMQ Team