From d0dcf9be757521688b56ef32890a1958790b86ca Mon Sep 17 00:00:00 2001 From: Roger Clark Date: Tue, 29 Mar 2016 20:23:14 +1100 Subject: [PATCH] Fix issue where not all lines are read from slow servers The while loop which reads the response from the server can finish before all data has been sent by the server, if the server returns the data slower than the code is reading it from the buffer. As in the example, the server is requested to close the connection after the data has been sent, the problem can be resolved by checking if the client is still connected to the server as well as checking if there is data in the client buffer using client.available() --- libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino index eb7c02eff3..6000b7dec6 100644 --- a/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino +++ b/libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino @@ -81,7 +81,7 @@ void loop() { } // Read all the lines of the reply from server and print them to Serial - while(client.available()){ + while(client.available() || client.connected()){ String line = client.readStringUntil('\r'); Serial.print(line); }