Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
May 14, 2018
Merged

Conversation

chemicstry
Copy link
Contributor

@chemicstry chemicstry commented May 6, 2018

WiFiClient::connected() incorrectly checks errno. If any other function before this call sets errno, the connected() returns false even though recv() result was 0. This is because recv function does not reset errno 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. Subsequent connected() call on a healthy connection would return false due to a previous set errno.

I propose a change to only check for errno if recv() call fails.

@Saulzi
Copy link

Saulzi commented May 9, 2018

I am having this issue. Looking forwards to when this is merged.

@me-no-dev me-no-dev merged commit 611db61 into espressif:master May 14, 2018
@me-no-dev
Copy link
Member

@Saulzi no need to wait anymore

@everslick
Copy link
Contributor

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.

@sansillusion
Copy link

I also use webserver in my project, and I have no issues with the commit ?
It even seem to be much faster than before ? The latest commits got my project to run properly without random crashes.

@everslick
Copy link
Contributor

@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.

@sansillusion
Copy link

@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.

@sansillusion
Copy link

looking at webserver.h (https://github.com/bbx10/WebServer_tng/blob/master/src/WebServer.h)
on line 50 there is a 2000ms delay for conection closing, could it be that the connection does not get closed and webserver has to wait for it's timeout ?

@everslick
Copy link
Contributor

yes, that could be, more specific it seems to be this code:

  if (_currentStatus == HC_WAIT_CLOSE) {
    if (millis() - _statusChange > HTTP_MAX_CLOSE_WAIT) {
      _currentClient = WiFiClient();
      _currentStatus = HC_NONE;
    } else {
      yield();
      return;
    }
  }

question remains, what's the right thing to do. :-/

@sansillusion
Copy link

@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.

@brainsucker-na
Copy link

brainsucker-na commented Jun 23, 2018

Yeah, sorry, that merge breaks some things (surprised no one reported that before) :(

Curclamas pushed a commit to Curclamas/arduino-esp32 that referenced this pull request Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants