Thingsboard cloud MQTT

liamm36
Posts: 4
Joined: Mon Jan 24, 2022 12:48 pm

Thingsboard cloud MQTT

Postby liamm36 » Wed Feb 09, 2022 4:05 pm

Hey,

Has anyone had any luck connecting to thingsboard cloud MQTT broker recently?

I've tried

Code: Select all

    esp_mqtt_client_config_t mqtt_cfg = {
    			.client_id="TbDev",
			.password=mypassword,
			.username=myusername,
			.uri =  "mqtt://cloud.thingsboard.io",
			.port = 1883,
		//.username = mqtt_access_token
    };
where password and username were from a device created on thingsboard.

I also tried using access tokens and following thingsboard example where the username is the token.

Code: Select all

    const char *mqtt_url = get_mqtt_url(running_partition_label);
    const uint32_t mqtt_port = get_mqtt_port(running_partition_label);
    const char *mqtt_access_token = get_mqtt_access_token(running_partition_label);

    esp_mqtt_client_config_t mqtt_cfg = {
        .uri = mqtt_url,
        .event_handle = mqtt_event_handler,
        .port = mqtt_port,
        .username = mqtt_access_token
    };
I've tried both the esp-idf MQTT tcp example and thingsboards own ota example (which still communicates via MQTT with their broker) https://github.com/thingsboard/esp32-ota. I have been using the master branch and thingsboard recommends ESP-IDF version 3.3. A few events were unhandled by the MQTT event handler which caused an initial build failure but adding them to the case switch statement built the project.

In both cases I get
"MQTT_CLIENT: Connection refused, not authorized"

Are there any other credentials required other than access token or username/pass for a device?

I can use thingsboard from the esp-32 in Arduino SDK. I can connect to other MQTT brokers in ESP-IDF but cannot seem to get thingsboard working.

Who is online

Users browsing this forum: Gaston1980 and 104 guests