HTTP Post request fails after sometime with error -1
Posted: Tue Jul 07, 2020 2:06 pm
Hi! I have an esp-12 module that connects to a server every 3 seconds and runs a php script, then reads the response.
I checked everything to make it work but every time it does it's job 3 to 5 times then reports error -1.
Here is my code for sending POST:
Could you please guide me to resolve this problem? Thanks.
I checked everything to make it work but every time it does it's job 3 to 5 times then reports error -1.
Here is my code for sending POST:
Code: Select all
HTTP.begin(ESP_HTTP_ADDRESS);
HTTP.setTimeout(300);
HTTP.addHeader("Content-Type", "application/json");
HTTP.addHeader("Content-Length", String(JSON.length()));
int RESPONSE = HTTP.POST(JSON);
if (RESPONSE != HTTP_CODE_OK) {
Serial.print(F("Query submit failed: "));
Serial.println(RESPONSE);
} else {
Serial.println(F("Query submit successful."));
Serial.println(F("Reading HTTP response:"));
String RESULT = HTTP.getString();
Serial.println(RESULT);
}
HTTP.end();
Could you please guide me to resolve this problem? Thanks.