-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fix WiFiClient error handling #1388
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
Conversation
I am having this issue. Looking forwards to when this is merged. |
@Saulzi no need to wait anymore |
This commit broke the webserver. The very first GET is fast but each subsequent GET is delayed exactly 2000ms. Which makes page loads which have more then one GET painstakingly slow. I zoomed in on this commit using git bisect. |
I also use webserver in my project, and I have no issues with the commit ? |
@sansillusion do you load more then ONE resource on page loads? if yes, are your page loads still fast when you SHIFT reload the page (this fetches the resources from the server, omitting the local browser cache). I double checked by reverting this one commit and pages load fast again afterwards. |
@everslick you are right, I had minimize request to a minimum in my project. If I reload right after a request there do seem to be a 2000ms delay. But single page loads seem fast after that 2000ms delay, while before I would get random delays BEFORE ANY page loads. |
looking at webserver.h (https://github.com/bbx10/WebServer_tng/blob/master/src/WebServer.h) |
yes, that could be, more specific it seems to be this code:
question remains, what's the right thing to do. :-/ |
@everslick I have tried changing the timeout value from 2000ms to 200ms and it seem to have sped-up the whole thing. I have not seen any error arise from it too. I have no idea why there should be a delay there but it works with a much smaller delay here. |
Yeah, sorry, that merge breaks some things (surprised no one reported that before) :( |
WiFiClient::connected()
incorrectly checkserrno
. If any other function before this call setserrno
, theconnected()
returns false even thoughrecv()
result was 0. This is becauserecv
function does not reseterrno
variable on successful operation and old unknown value is used in switch.This behaviour can be observed when using multiple
WiFiClient
objects and one of them disconnects with an error. Subsequentconnected()
call on a healthy connection would return false due to a previous seterrno
.I propose a change to only check for
errno
ifrecv()
call fails.