electronicsguy / HTTPSRedirect

A library for seamless data logging, communication and control for Internet of Things
GNU Affero General Public License v3.0
59 stars 26 forks source link

Hangup of the Logging when Internet connection is shortly interrupted #8

Open kipet1 opened 2 years ago

kipet1 commented 2 years ago

Hi, i am logging my home energy data with ESP8266 into Google sheets with httpsredirect, following the directions given in: https://github.com/StorageB/Google-Sheets-Logging

My ESP goes in hangup occasionally when the internet gets interrupted shortly. The Wemos D1 gets stuck exactly during if(client->POST(url, host, payload)){ No error message, I can only pull it out by hard reset.

I was already playing days with the watchdog of the ESP, as this should act to pull it out or restart the device. But this is only partially successful, for some unknown strange reason, the watchdog is not always recognizing it. I didn't succeed to get a reliable logging, which is important, not to loose too many data of my home energy monitoring, including future solar power charge control of electric car.

I would appreciate, if there could be done some improvement inside the httpsredirect of error handling, or implementation of a timeout (e.g 10sec), if the post is not finalized after this time. Thanks, regards, Peter

github-actions[bot] commented 2 years ago

Welcome to HTTPSRedirect! Please provide enough info to debug the issue.

kipet1 commented 2 years ago

Here is the part of the code:

`void sendtoGoogle() { static bool flag = false; if (!flag){ client = new HTTPSRedirect(httpsPort); client->setInsecure(); flag = true; client->setPrintResponseBody(true); client->setContentTypeHeader("application/json"); } if (client != nullptr){ if (!client->connected()){ client->connect(host, httpsPort); } } else{ Serial.println("Error creating client object!"); }

// Create json object string to send to Google Sheets payload = payload_base + "\"" + Power0 + "," + Power1 + "," + Power2 + "," + Etotret0 + "," + Etot1 + "," + Etot2 + "\"}";

Serial.println(WiFi.status());

ESP.wdtFeed();

Serial.print("Publishing.. " ); Serial.println(millis()-start_10S);

if(client->POST(url, host, payload)){ //<---------------------- Hangup in case of internet connection interruption Serial.print(" "); Serial.println(millis()-start_10S);
} else{ // do stuff here if publish was not successful Serial.println("Error while connecting"); }

Serial Monitor: 14:15:20.404 -> Start Shelly 3 14:15:20.457 -> Publishing.. 61 14:15:23.953 -> Success 14:15:23.953 -> 3556 <- successfull publish, repeated each 15 seconds, the post lasts about 3.5sec

14:15:35.437 -> Start Shelly 3 <- shortly before the internet connection starts interruption for about 10 seconds 14:15:35.500 -> Publishing.. 60 <- Here it hangs forever inside POST....

kipet1 commented 2 years ago

Any comment would be appreciated

ahmdgamaljimy95 commented 1 year ago

hi @kipet1 did you solve this issue ? i have this problem and cant solve it till now ?

kipet1 commented 1 year ago

Hi, as i did not get any answer here from electronicsguy, i discussed this issue in other posts and found the solution, see here: https://github.com/StorageB/Google-Sheets-Logging/issues/7