- Fri Jul 13, 2018 2:24 pm
#77029
I have a sumilar (or the same) problem. An esp8266 running as a client requests data from a server. After about 730 requests the client stops.
Tried several ESP versions, all have the same problem.
Tried a different server, same problem.
Tried ThingsPeak as server, same problem.
I want to check the status of a sensor every second over my WiFi network. Als long as the client stops every 730 requests, i cannot proceed with this project.
Help is appreciated.
The loop-code is:
void loop()
{
ledState = !ledState;
digitalWrite(LEDPin, ledState); // ring a bell to signal that server is death
Serial.print("Retrieve from TS. ");
if (now() - lastCheck > 3)
{
if (!client.connected())
{
while (!client.connect(host, 1002)) // get some data back from TS
{
Serial.println("connection failed");
delay(1000);
client.stop();
}
}
requestNumber++;
client.print(String("GET /") + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
client.flush();
answerTimeout = millis() + 10000;
Serial.print(" Request number: ");
Serial.print(requestNumber);
while (answerTimeout > millis())
{
i = 0L;
while (client.available())
{
i++;
char aChar = client.read();
answerTimeout = millis() + 200;
delay(1);
}
if (i > 0)
{
Serial.print(" Read characters: ");
Serial.println(i);
}
delay(1);
}
client.stop();
}
};
=============================================================================
I learned that the client is loosing 56 bytes free space every call I make to it.
When I went bach to the prevoius version of ESP8266WIFI, it works fine so fat. No more stops, no more memory losses