Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WifiClient example - Fix issue where not all lines are read from slow servers #1829

Closed
wants to merge 1 commit into from
Closed

Conversation

rogerclarkmelbourne
Copy link

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()

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()
@ghost
Copy link

ghost commented Apr 11, 2016

Can one of the admins verify this patch?

@devyte
Copy link
Collaborator

devyte commented Nov 5, 2017

This PR looks correct to me, and the relevant code is still present in the example in latest git.
In theory, a webserver could send data line by line. If after sending one line it takes too long to send the next, and the relevant while loop in the example empties the client buffer, on next iteration it will stop looping and be done, even though the reply is incomplete. Given that the headers specify Connection: close, it's ok to continue looping until connection is closed by the server.
@rogerclarkmelbourne the relevant branch is out of date with base branch. Could you please rebase?

@devyte devyte added component: examples type: bug waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Nov 5, 2017
@devyte devyte self-assigned this Jan 11, 2018
devyte added a commit that referenced this pull request Sep 7, 2018
@devyte
Copy link
Collaborator

devyte commented Sep 7, 2018

Replaced by #5113 .

@devyte devyte closed this Sep 7, 2018
devyte added a commit that referenced this pull request Sep 7, 2018
d-a-v pushed a commit to d-a-v/Arduino that referenced this pull request Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: examples type: bug waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants