Chat freely about anything...

User avatar
By m.maazi
#87798 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:

Code: Select allHTTP.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.
User avatar
By m.maazi
#87808 Hi. Thanks for helping me.
Posting all my code might be a problem! It's about 10000 lines of code in 40 pages. I stripped my post request code to it's essential commands. My post request is about 300 lines of building a long JSON body for post and decoding an even longer JSON response. I can upload my code.
And about Wireshark. I don't really know how to do it.
Sorry for my poor English.