esp8266 / esp8266/Arduino

WiFiClientSecureCtx: hardcoded timeout

Open
#8,203 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Problem Description
[WiFiClientSecure](../blob/master/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h#L242-L244) doesn't propagate timeout to `WiFiClientSecureCtx`.
`WiFiClientSecureCtx` has [hardcoded timeout 15000ms](../blob/master/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp#L76), which is [changed to 5000ms](../blob/master/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp#L252) after successfull secure connection.

When using HTTPClient, its timeout is progated to an underlaying `WifiClient` instance in the [sendRequest](../blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp#L298).

I understand that secured connecting requires higher timeouts. I suggest introducing a configurable *connection timeout* and distinguish it from the current used *read timeout*.

### Basic Infos

- [X] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] I have filled out all fields below.

#### Platform

- Hardware: [ESP-12F]
- Core Version: [2021-07-09]
- Development Env: [Arduino IDE]
- Operating System: [Windows]

### Settings in IDE

- Module: [D1 Mini Clone]
- Flash Mode: [DOUT]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [N/A]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [921600]

### [MCVE](https://stackoverflow.com/help/mcve) Sketch

```cpp

#include

#include

#include

void setup() {

Serial.begin(74880);

Serial.println();
Serial.println("WifiClientSecure timeout test");

WiFi.mode(WIFI_STA);
//WiFi.begin("SSID", "PASSWORD");
WiFi.begin("Bonitoo-ng", "change1t");
}

void loop() {
// wait for WiFi connection
if (WiFi.isConnected()) {
BearSSL::WiFiClientSecure client;
client.setTimeout(4000);
uint32_t start = millis();
int r = client.connect("www.google.com",440);
Serial.printf("Connection took: %lums\n", millis()-start);
if(r) {
client.stop();
}
}

Serial.println("Wait 10s before the next round...");
delay(10000);
}
```

### Debug Messages

```
WifiClientSecure timeout test
Wait 10s before the next round...
Connection took: 15597ms
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.