Client is not authorized to connect

@Daria_H
Thank you for your supprt.

Below is information you request.

  1. This picture to confirmed that my cluster work for web socket port 8884.

  2. Here is the source code that I used for evaluate. As you can see that it is very easily to switch between HiveMQ Cloud cluster & http://test.mosquitto.org:8885 by just comment out #define USE_HIVEMQ_CLOUD

#define USE_HIVEMQ_CLOUD

#ifdef USE_HIVEMQ_CLOUD
#define MQTT_BROKER “a02edcfce43443e09599dbb82cbc2672.s1.eu.hivemq.cloud”
#define MQTT_PORT (8883)
#define MQTT_USER_NAME “TestDevice001”
#define MQTT_PASSWORD “xxxxxxxx”

char* rootCABuff = "-----BEGIN CERTIFICATE-----\n" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \
"-----END CERTIFICATE-----\n";

#else
#define MQTT_BROKER “test.mosquitto.org
#define MQTT_PORT (8885)
#define MQTT_USER_NAME “rw”
#define MQTT_PASSWORD “readwrite”

char* rootCABuff = "-----BEGIN CERTIFICATE-----\n" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n" \
"-----END CERTIFICATE-----\n";

#endif

char* address = MQTT_BROKER;
char * username = MQTT_USER_NAME;
char * password = MQTT_PASSWORD;

NetworkInit(&network);
network.rootCA = (char*)rootCABuff;
network.clientCA = NULL;
network.private_key = NULL;
network.use_ssl = 1;
MQTTClientInit(&client, &network, 30000, sendbuf, sizeof(sendbuf), readbuf,sizeof(readbuf));

mqtt_printf(MQTT_INFO, “Connect Network "%s"”, address);
while ((rc = NetworkConnect(&network, address, MQTT_PORT)) != 0){
mqtt_printf(MQTT_INFO, “Return code from network connect is %d\n”, rc);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
mqtt_printf(MQTT_INFO, “"%s" Connected”, address);

connectData.username.cstring = username;
connectData.password.cstring = password;
connectData.MQTTVersion = 4; // 4 = Version 3.1.1
connectData.clientID.cstring = “Device001”;
connectData.cleansession = 1;

mqtt_printf(MQTT_INFO, “Start MQTT connection”);
while ((rc = MQTTConnect(&client, &connectData)) != 0){
mqtt_printf(MQTT_INFO, “Return code from MQTT connect is %d\n”, rc);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
mqtt_printf(MQTT_INFO, “MQTT Connected”);

  1. For the server certificate.
    Below is for test.mosquitto.org
    https://test.mosquitto.org/ssl/mosquitto.org.crt

And for HiveMQ Cloud Cluster I picked up follow below FAQs.

My device requires a server CA file to connect via TLS. How can I generate this for my HiveMQ Cloud instance?

https://community.hivemq.com/t/frequently-asked-questions/514

Then, server certificate embed to above char* rootCABuff code.

Regards,