Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kipet1 opened this issue Sep 6, 2022 · 11 comments
Open

Comments

@kipet1
Copy link

kipet1 commented Sep 6, 2022

HI,
my logging goes in hangup occasionally (1-2 times /week), this is boring.
The Wemos gets stuck exactly during
if(client->POST(url, host, payload)){
It happens, when exactly during post the internet gets disconnected for a short while. My router makes each day a reconnect with interruption of connection to get a new IP. It is not so rare, that this is falling just into the post procedure, as this takes about 3 seconds, each 15seconds.
Before the post i get the info "Publishing ...", then nothing happens anymore, it stays forever, no return of Success or error message. (Before post Wifi and client was connected)
I need to reset the Wemos to restart.

Does anybody have an idea of rootcause and/or countermeasure?

This is my code of that part, like in your example:

// Publish data to Google Sheets

int retval = client->connect(host, httpsPort);
Serial.print("Client: ");Serial.println(retval);
Serial.println(WiFi.status());

Serial.println("Publishing...");
//Serial.println(payload);
if(client->POST(url, host, payload)){
Serial.println("successful");
}
else{
// do stuff here if publish was not successful
Serial.println("Error while connecting");
}

@rret
Copy link

rret commented Sep 6, 2022 via email

@kipet1
Copy link
Author

kipet1 commented Sep 9, 2022

I was assuming, something could be done inside the google script, but it is no more in the loop, when the hangup occurs.
Your watchdog suggestion brought me to the solution.
The ESP8266 has a SW and HW watchdog on board, but they have strong limitations and do not work straightforward.
I disabled the SW watchdog with
ESP.wdtDisable(); //SW WD disable, only HW
And reset (feed) the HW WD every loop round and before the POST request.
ESP.wdtFeed();
This pulls it out from hangup after about 8sec.
I was not sure, if this works, but it solves the issue.
Thanks, regards Peter

@kipet1 kipet1 closed this as completed Sep 9, 2022
@rret
Copy link

rret commented Sep 10, 2022 via email

@kipet1 kipet1 reopened this Sep 14, 2022
@kipet1
Copy link
Author

kipet1 commented Sep 14, 2022

Hi,
unfortunately it turned out, that the solution with the WD is not working reliably. Testing it at the beginning 2 times by manually interrupting the DSL, it worked perfect, and i was happy. But it turns out, that it gets still locked sometimes at the POST request.
I do not yet have any clue, why the watchdog is not biting reliable, still searching for a solution.
In the moment, the internet gets short interruptions several times during the night, maybe some maintenence. Every night i got one hangup.

@rret
Copy link

rret commented Sep 14, 2022 via email

@kipet1
Copy link
Author

kipet1 commented Sep 22, 2022

Hi rret,
as this issue is still pending, and also the electronicguy for the httpsdirect library does not answer, please give me some more info about your recommended WDT.
The price is not the big issue, but the work to add it into my device inside the case.
I cannot find such a thing on ebay. I only find a 3 pin device DS1233, which supervises the supply as watchdog, not really suitable. Thanks, Peter

@rret
Copy link

rret commented Sep 22, 2022 via email

@kipet1
Copy link
Author

kipet1 commented Sep 22, 2022

Thanks for your information.
I couldn't find it, because process2 does not sell to germany.
Also the circuit looks not really smart, with a huge cap.
I have the idea now, to put a second Wemos 8266 on top of it, the pins are then compatible, they superwise each other.
It sounds like an overkill, but this is much cheaper, fully programmable, and smaller.

@rret
Copy link

rret commented Sep 23, 2022 via email

@ramchandrashinde
Copy link

As you have mentioned that after **if(client->POST(url, host, payload)) ,

My suggestion :
just go thorugh the HTTPSREdirect.cpp in that you can find that there are some while loops which can be dangerous in case of lost connectivity or slow internet connecitvity as per below ,

// Clear the input stream of any junk data before making the request

while(available())

read();

while (connected()) {

In case of connectivity issue you can change these above while loops with for loop by setting some time limit and you can come out of that loop and do the next acitivity from your algorithm.

just try it out and let us know

@kipet1
Copy link
Author

kipet1 commented Dec 17, 2022

Thanks for your hints,
as this issue is already pretty old, i implemented successfully the watchdog with a 2nd wemos, as described above.
I tried to implement some timeout, but i didn't succeed for unknown reason.
lateron i found in other posts some countermeasure. I implemented the simple one with "return true", and the hangup is removed. I do not get anymore any responsestatus, but this is not so important for me.
electronicsguy/ESP8266#84
I do not understand, why not any countermeasure of this known problem had been implemented in several later updates of the Httpsredirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants