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

Moderator: igrr

User avatar
By RussNZ
#81227 Hi, I'm having trouble using ESP8266 on a local server but not remote servers. If I GET request a remote server with PHP the response is very fast. If I try to execute the exact same PHP script on a local server (I've tried Windows XAMPP installation and a Raspberry Pi with manually installed Apache and PHP and I've tried two different networks, problem is the same across all).

All the PHP file I'm trying to execute is doing is printing a single character and nothing else. Literally:
Code: Select all<?php echo 'a'; ?>


If I GET request this from somedomain.com/a.php the response is instant.
If I GET request 192.168.1.10/a.php (local server IP) it takes over 5 seconds for the character to be printed. Requesting HTML pages with no PHP is instant on local server, it is only PHP code that is slow.

My Sketch Code:
Code: Select all#include <Wiegand.h>
#include <ESP8266WiFi.h>

// Network Credentials and server IP
const char* ssid = "ssid";
const char* password = "pass";
const char* host = "192.168.1.10";

void setup() {
  Serial.begin(9600);

  Serial.printf("Connecting to the network: %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println(" successfully connected");
}

void loop() {
  WiFiClient client;

    Serial.printf("\n[Connecting to %s ... ", host);
   
    if (client.connect(host, 80)) {
      Serial.println("connected]");
      Serial.println("[Sending a request]");
      client.print(String("GET /a.php") + " HTTP/1.1\r\n" +
                   "Host: " + host + "\r\n" +
                   "Connection: close\r\n" +
                   "\r\n"
                  );
    }
   
    Serial.println("[Response:]");
   
    while(client.connected() || client.available()) {
      if(client.available()) {
        String line = client.readStringUntil('\n');
        Serial.println(line);
      }
    }
    client.stop();
    Serial.println("\n[Disconnected]");
  }

}
User avatar
By RichardS
#81314 Hmm... thanks for the follow up and not leaving us hanging... seems a lot of people post, issues, and when they find solution they just move on.... :?

Thanks!!

RichardS