HTTPClient Get Timeout?

Is there any timeout at "client.available()"? In my opninion not. It's stuck in the while loop if you move out of the wifi range. Is there a way to get a timeout?


HttpClient client; client.get("");

while (client.available()) { char c =; Serial.print(c); } Serial.flush();

Thanks for your help.

from “HttpClient.cpp”

unsigned int HttpClient::get(String &url) {
return run();

Rewrite HttpClient by use directly Process.

curl -h
--connect-timeout SECONDS  Maximum time allowed for connection
-m, --max-time SECONDS  Maximum time allowed for the transfer
  Running process using Process class.

 This sketch demonstrate how to run linux processes
 using an Arduino Yún.

 created 5 Jun 2013
 by Cristian Maglie

 This example code is in the public domain.


#include <Process.h>

void setup() {
   // Initialize Serial

  // Wait until a Serial Monitor is connected.
  while (!Serial);

void loop() {
  // Do nothing here.
  Process p;              
   // Print command output on the Serial.
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c =;
  // Ensure the last bit of data is sent.

Is there a way to check if the timeout did occur ? Or is the only way to add a Millis() counter?

 curl -s -I --connect-timeout 5 --max-time 10 | grep -q '200 OK';

use -I only check header.

I don’t think that’s what i meant. I mean, if a timeout occurs, how can i get a notification
that it had been that way ? I need to post certain interrup counts with curl but when they
are not posted alright the interrupt count doesn’t need to be reset to 0, he’ll just retry next
time and adds the count then.

if you know what i mean :slight_smile:

I think curl will exit with an exitValue greater than 0 if an error occurs. Check exitValue() from both Process and HTTPClient