Making a counter for the HttpClient on ESP8266

Hey falks,

I am using this HTTP-Client request:

String serverPath = "http://myHomepage.page";

http.begin(client, serverPath.c_str());

httpResponseCode = http.GET();

if (httpResponseCode>0)
{

// Type your main code here

}

My Problem is: sometime the server takes a little time for responding. Is it possible to build in a counter to break the code and move on with the rest of the code on my ESP ?

The problem is: there is a DC-Motor also running on "the rest code". As I said: sometimes it takes several seconds for a respond. My you guys do have a way to break it and move on ?

Thanks, and Greetings from Germany.

May something like this:

int Counter=0;
while(httpResponseCode<1)
{
Counter++;
}
Counter=0;

Or should I put this code in the while() method ?

http.begin(client, serverPath.c_str())

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.