Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
  • Loading branch information
rogerclarkmelbourne committed Mar 29, 2016
commit d0dcf9be757521688b56ef32890a1958790b86ca
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down