ArduinoHttpClient
ArduinoHttpClient copied to clipboard
Setting a maximum timeout
I've poked around the code, example ino files, issues, and arduino forums for this, but I can't seem to find a reliable way to set a timeout for the HTTP request.
My code, essentially, boils down to this:
void send_data() {
unsigned long millistart = millis();
String url = "id=somedatahere";
// new client each time
HttpClient http(client, traccar_server, traccar_port);
// start for the / url, and set some timeouts
http.beginRequest();
http.setTimeout(5000);
http.setHttpResponseTimeout(5000);
int err = http.post("/", "application/x-www-form-urlencoded", url);
http.endRequest();
SerialMon.println("> post done (" + String((millis() - millistart)/1000.0,2) + "s)");
}
(The above is paraphrased and not necessarily working code, the full code is available here but has all kinds of other GPS/data/modem stuff going on as well.)
Yet I routinely see the "post done" showing times well in excess of 10 seconds and sometimes even up to 75 seconds or so (which is a real fishy number, like a 60s timeout on top of a 15s from something else).
Setup info:
- Device:
LILYGO T-SIM7000G ESP32-WROVER-B
- Arduino IDE 2.1.0
- ArduinoHttpClient 0.4.0
How can I set a overall timeout for a given HTTP request?