Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Daniel Dsouza
#35358 Hello,
Not sure if this is the right category for this doubt.

I'm trying to use HTTP GET requests on the esp.
Whenever i use GET requests with adafruit or google i get a response back . However if i use GET requests with my own site, it does not get a response back but the value gets updated in the databases. It does not enter the while(client.available()) loop.
As such i'm assuming that theres something probably wrong with my php script. If anyone has had any success in accomplishing this, let me know.

Thanks in advance.
User avatar
By torntrousers
#35439 You really need to show your code, but as a guess it could be you don't wait long enough for the response. So if your code is something like this:
Code: Select all 
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");

  delay(10);   //  <<<********  10 is often too shorta delay
 
  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){

then try increasing the delay value.
User avatar
By martinayotte
#35449 Or even better, using a while loop which wait for a response until a timeout :

Code: Select all    int timeout = millis() + 5000;
    while (client.available() == 0) {
      if (timeout - millis() < 0) {
        p.println(">>> Client Timeout !");
        client.stop();
        return;
      }
    }
User avatar
By torntrousers
#35455
martinayotte wrote:Or even better, using a while loop which wait for a response until a timeout :

Code: Select all    int timeout = millis() + 5000;
    while (client.available() == 0) {
      if (timeout - millis() < 0) {
        p.println(">>> Client Timeout !");
        client.stop();
        return;
      }
    }


+1, though i also include a delay or yield in the loop to avoid the WDT, is that necessary?