GoogleCloudPlatform/google-cloud-iot-arduino

device disconnects after 3 days

wasap opened this issue · 1 comments

wasap commented

error message: [14] mqtt: SERVER: The connection is closed because the server is shutting down.
and after this device is connected to wifi but mqtt remains disconnected and not connects again

wasap commented

that was my fault!
i use wemos d1 so inside void loop variable ESP8266_MQTT_H was not defined

{
  mqtt->loop();
  delay(10); // <- fixes some issues with WiFi stability

  if (!mqttClient->connected())
  {

    #ifdef ESP32
    connect();
    #endif

    #ifdef __ESP8266_MQTT_H__
    ESP.wdtDisable();
    connect();
    ESP.wdtEnable(0);
    #endif
  }

  // TODO: Replace with your code here
 if (millis() - lastMillis > 3600000)
 {
   lastMillis = millis();
   publishTelemetry(printBME280());
 }
}

and this code was not executed
ESP.wdtDisable(); connect(); ESP.wdtEnable(0);