-->
Page 1 of 1

ESP8266WebServer - HelloServer example - connection timeout

PostPosted: Thu May 21, 2015 4:32 pm
by M0ebius
I have a problem with the ESP8266WebServer.
The helloserver example compiles, uploads and runs - but it does not accept connections.
I always get a connection timeout.

In the file esp8266webserver.cpp, the line "WiFiClient client = _server.available();" never returns a valid client.

But it works, if i implement a server "by hand":
Code: Select all#include <ESP8266WiFi.h>
const char* ssid = "....";
const char* password = "...";

WiFiServer server(80);

void setup()
{
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFiStart();
}

void WiFiStart()
{
  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");
 
  server.begin();
  Serial.println("Server started");

  Serial.println(WiFi.localIP());
}

void loop()
{
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client)
  {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println("new client");
  unsigned long ultimeout = millis()+250;
  while(!client.available() && (millis()<ultimeout) )
  {
    delay(1);
  }
  if(millis()>ultimeout)
  {
    Serial.println("client connection time-out!");
    return;
  }
 
  // Read the first line of the request
  String sRequest = client.readStringUntil('\r');
  //Serial.println(sRequest);
  client.flush();
 
 // Send the response to the client
  client.print("header");
  client.print("body");
 
  // and stop the client
  client.stop();
  Serial.println("Client disonnected");
}

How can i fix it?
(Win 8.1-64, Arduino 1.6.4 with package 628-545ffde)

Re: ESP8266WebServer - HelloServer example - connection time

PostPosted: Fri May 22, 2015 6:13 am
by M0ebius
Problem solved.
I've cleaned the temp directory (no "make clean" available) - i guess there was some garbage from a previous build / version.