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

Moderator: igrr

User avatar
By Falesh
#37831 When I run the sketch below to connect to adafruit it takes about 50ms. When I run it to connect to my local server, XAMPP on my PC, it takes 1000ms. When I connect to the local server from my other PC it loads almost instantaneously so it's not the local server that is slow. Does anyone have any idea why this might be?

Code: Select all/*
 *  Simple HTTP get webclient test
 */
 
#include <ESP8266WiFi.h>
 
const char* ssid     = "virginmedia545641";
const char* password = "mypassword";
 
const char* host = "192.168.0.10";
//const char* host = "www.adafruit.com";

String url = "/electronics/test.php";
//String url = "/testwifi/index.html";
const int httpPort = 80;
String remoteData;

 
void setup() {
  Serial.begin(115200);
  delay(100);
 
  // We start by connecting to a WiFi network
 
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}
 
void loop() {
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  unsigned long testStartTime = millis();
 
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
 
  // This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  delay(1);
 
  // Read all the lines of the reply from server and print them to Serial
  while(client.available()){
    remoteData = client.readStringUntil('\r');
  }
  Serial.println(millis() - testStartTime);
  //Serial.println(remoteData);
  //delay(3000);
}
User avatar
By Falesh
#37880 The PC connects to a router which connects to the Virgin Hub which connects to the local server, all via cable. Both the PC & ESP8226 used the same url to get the page, the PC used Firefox as the browser. I tried connecting the ESP8226 wirelessly to both the router and the Virgin Hub, the results were the same.