ESP32 IDF and AWS MQTT
Posted: Wed Mar 27, 2024 9:11 pm
Hi!
I am trying to connect to the MQTT service of AWS IoT using the MQTT API of the ESP32 IDF, and I have the following code:
In the event handler it receives an TCP_TRANSPORT_ERROR when using the structure of "mqtts://aws_endpoint:8883" there is any other thing I need to configure? or is any parameter not valid here? certificate and private_key are both given by the AWS IoT core certificates being the certificate .pem.crt and the key .pem.key.
Thanks in advance!
I am trying to connect to the MQTT service of AWS IoT using the MQTT API of the ESP32 IDF, and I have the following code:
Code: Select all
char complete_uri[60];
sprintf(complete_uri, "mqtts://%s:%d", url, port);
const esp_mqtt_client_config_t mqtt_cfg = {
.broker = {
.address ={
.uri = complete_uri
},
.verification.certificate = certificate,
},
.credentials = {
.authentication ={
.key = private_key
},
.client_id = client_id
}
};
esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
esp_mqtt_client_register_event(client, ESP_EVENT_ANY_ID, mqtt_event_handler, NULL);
esp_err_t conn_validation = esp_mqtt_client_start(client);
Thanks in advance!