Closed brnyza closed 5 years ago
Hi, it is difficult to say what is happening in your specific case without having detailed information. Anyway I can share my experience: I have a similar problem when the client tries to connect and internet is not available. In my case, the ESP8266 does not crash but just waits for the internet connection. In order to make the code more robust, you can check for the wifi status (WiFi.status() == WL_CONNECTED) to be sure that at least the wifi client is connected to the AP. This will not solve the problem in the case there is a wifi connection but internet is not available. I solve this specific problem with a ping but so far the code is buggy and the esp8266 crashes. Bye and happy Xmas time.
Updated for compatibility with latest version of esp8266 library (2.5.0-beta2). Please use this and report back.
Thank you! Now is working!
Sorry for the wrong information, but unfortunately, the error keeps occurring with "2.5.0-beta2". Sometimes ESP8826 restart when there is an error and is OK. But other times ESP88266 breaks, and I have to do a Hardware Reset.
If I stops 3G(internet), or only the Wifi, during this command, from my cellphone, the ESP8266 stops working
Hi, I had a similar problem. In my case the problem arose when the internet connection was interrupted and the http client was still in use. I have solved the problem by creating a new client every time a send request is performed. In this case, if there is no internet connection, the client is not created and the system does not hang waiting for the internet connection. I hope it helps.
Hi pierangelof! Just to be clear, for each command you: 1st - Clear the client like this:
delete client;
client = nullptr;
2nd - After, you create the client again?
client = new HTTPSRedirect(httpsPort);
client->setInsecure();
client->setPrintResponseBody(true);
client->setContentTypeHeader("application/json");
client->connect(host, httpsPort);
@brnyza Could you list out the exact steps for me to reproduce the issue?
Dear @electronicsguy
It occurs in the step below: The POST command is taking about 3 sec. During this time, if I turn off the provided Wifi from cellphone, the ESP breaks.
Serial.println(millis());
Serial.println("BEGIN");
if(client->POST(urlCal, host, payload, true)) {
RetornoPost = client->getResponseBody();
}
else {
++error_count;
}
Serial.println("END");
Serial.println(millis());
Hi pierangelof! Just to be clear, for each command you: 1st - Clear the client like this:
delete client; client = nullptr;
2nd - After, you create the client again?
client = new HTTPSRedirect(httpsPort); client->setInsecure(); client->setPrintResponseBody(true); client->setContentTypeHeader("application/json"); client->connect(host, httpsPort);
Hi, correct, what you wrote is more or less what I meant. You could also think to write the code to post the data in a function and to use a local variable for the client.
Hi @pierangelof, I've modified the code to POST the data in a function, using local variable, but ESP8266 still breaks, if I don't provide WiFi.
Hi @brnyza ,
in my case, the problem was generated by an interruption of the communication on the WAN side but the WLAN connection was still available. In your case, you could use a conditional clause in order to be sure that the data are sent only if there is a WLAN connection. Something like:
if (WiFi.status() == WL_CONNECTED) { _[post the data to gcloud]_ }
I hope it helps.
To test the WiFi connection I'm sharing the WiFi of my cellphone.
If I stop the WiFi sharing during the command below, the ESP8266 stops working. It only works if I do a hardware reset.
If I don't stop the WiFi it works normally.
if(client->POST(urlCal, host, payload))
{ RetornoPost = client->getResponseBody(); }
Does anyone know why ESP8266 stops working?