Skip to content

Fix for timeout issues on WebServer.cpp #8319

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
Jun 29, 2023

Conversation

supersjellie
Copy link
Contributor

Description of Change

Removing client temporary variable. Arduino doesn't like copying objects. And for the logisch de class variable _currentClient can be used from the start of the method

Tests scenarios

My openHAB server calls 3 ESP32 devices every minute. In the openHAB log about 5-10% fails on a timeout (3000 ms is set timeout on openHAB). With above code modification none (running for 3 days now) of the calls failed.

Related links

#8318

(same issue and resolution for ESP8266, check esp8266/Arduino#8941 )

@CLAassistant
Copy link

CLAassistant commented Jun 15, 2023

CLA assistant check
All committers have signed the CLA.

@SuGlider SuGlider self-assigned this Jun 20, 2023
@SuGlider SuGlider added the Area: BT&Wifi BT & Wifi related issues label Jun 20, 2023
@SuGlider SuGlider added this to the 2.0.10 milestone Jun 20, 2023
@SuGlider
Copy link
Collaborator

SuGlider commented Jun 21, 2023

@supersjellie @me-no-dev

I have tested this PR and it works with no errors.
I used the WebServer HelloServer.ino example to test server.handleClient();
I couldn't notice any difference from the original code to the PR code.
I get a few errors in the WiFi Client in both cases:

[ 16123][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 26460][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 26463][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 36087][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 46242][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 56364][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128
[ 66167][D][WiFiClient.cpp:546] connected(): Disconnected: RES: 0, ERR: 128

@supersjellie
Copy link
Contributor Author

supersjellie commented Jun 21, 2023

I couldn't notice any difference from the original code to the PR code.

No differences in response time when your refresh 'like crazy'? In my setup (of course I use a bigger/more complicated sketch than the helloserver.ino) the difference is large. Most requests are the same but with the old code about 5-10% had large response times. And with the new code this disappeared.

@SuGlider @me-no-dev : Got curious to the why and performed an extra test and now think the ESP32 timeouts were collateral damage of the ESP8266 bug.

Setup:

  1. Change refresh rate of 1 ESP32 webservice in openHAB to 10 seconds
  2. New code, no timeouts in 1 hour
  3. Old code, no timeouts in 1 hour
    Same as you observed. Difference with previous testsetup is that all ESP8266 devices are "patched" now. They don't timeout anymore. So ... maybe the timeouts on the ESP32 devices are collateral damage caused by the timeouts on the ESP8266. Also no network expert but thinking of some general issues in the "webservice traffic" (maybe by blocking all connections in the pool used by the openHAB server).

What would mean that for the ESP32 this code modification is more cosmetic, saving an unneeded variable and keeping it in synch with the ESP8266 code.

@SuGlider
Copy link
Collaborator

What would mean that for the ESP32 this code modification is more cosmetic, saving an unneeded variable and keeping it in synch with the ESP8266 code.

Yes, this PR may save a few cycles and some stack allocation in execution time.
@me-no-dev - It is an improvement, anyway, therefore, I think that we should merge it.

@SuGlider SuGlider requested review from me-no-dev and SuGlider June 23, 2023 11:54
@me-no-dev me-no-dev merged commit 1c3384c into espressif:master Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues
Projects
Development

Successfully merging this pull request may close these issues.

4 participants