How to reconnect MQTT with new config
Posted: Fri Feb 15, 2019 11:58 am
Hi
I am trying to change the config of my MQTT client and reconnect to the broker, as the username and password can be changed. This is over a TLS connection. Currently, I am trying:
However, I get the following:
E (1666107) MQTT_CLIENT: Client has not connected
E (1668167) esp-tls: mbedtls_ssl_setup returned -0x7f00
E (1668167) esp-tls: Failed to open new connection
E (1668167) TRANS_SSL: Failed to open a new connection
E (1668177) MQTT_CLIENT: Error transport connect
Does anyone have any suggestions?
The MQTT client that was originally set wasn't connected to the broker in the first place, but it looks like it keeps trying until I do the above. Do I need to create a completely new config for doing this, or is config re-use OK?
Any help will be greatly appreciated.
I am trying to change the config of my MQTT client and reconnect to the broker, as the username and password can be changed. This is over a TLS connection. Currently, I am trying:
Code: Select all
mqtt_config.username = mqtt_username;
mqtt_config.password = mqtt_password;
ESP_LOGI(TAG, "Password set to %s", mqtt_password);
//Swap config and restart client
if(started){
esp_mqtt_client_stop(mqtt_client);
esp_mqtt_set_config(mqtt_client, &mqtt_config);
esp_mqtt_client_start(mqtt_client);
}
E (1666107) MQTT_CLIENT: Client has not connected
E (1668167) esp-tls: mbedtls_ssl_setup returned -0x7f00
E (1668167) esp-tls: Failed to open new connection
E (1668167) TRANS_SSL: Failed to open a new connection
E (1668177) MQTT_CLIENT: Error transport connect
Does anyone have any suggestions?
The MQTT client that was originally set wasn't connected to the broker in the first place, but it looks like it keeps trying until I do the above. Do I need to create a completely new config for doing this, or is config re-use OK?
Any help will be greatly appreciated.