1) MQTT client connected to broker (mosquitto);
2) Messages are being sent to broker normally;
3) after while mosquitto is down,
4) MQTT client reports disconnection;
5) mosquitto is up again and working normally, network connection valid (ping answers);
4) MQTT client cannot reconnect any more, log: "MQTT_CLIENT: Client force reconnect requested"
I use code modified, based on MQTT example https://github.com/espressif/esp-idf/tr ... s/mqtt/tcp:
Code: Select all
case MQTT_EVENT_DISCONNECTED:
ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
ESP_LOGI(TAG, "Trying to reconnect...");
xFrequency = 2*1000 / portTICK_PERIOD_MS;
xLastWakeTime = xTaskGetTickCount();
for( ;; )
{
ESP_LOGI(TAG, "another attempt ...");
vTaskDelayUntil( &xLastWakeTime, xFrequency );
esp_err_t err = esp_mqtt_client_reconnect(client); // <====== it seems not working !!!
if (err != ESP_OK) ESP_LOGI(TAG, "reconnect error !");
}
break;