All the PHP file I'm trying to execute is doing is printing a single character and nothing else. Literally:
<?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:
#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]");
}
}