Skip to content

WiFiClientSecureCtx: hardcoded timeout #8203

@vlastahajek

Description

@vlastahajek

Problem Description

WiFiClientSecure doesn't propagate timeout to WiFiClientSecureCtx.
WiFiClientSecureCtx has hardcoded timeout 15000ms, which is changed to 5000ms after successfull secure connection.

When using HTTPClient, its timeout is progated to an underlaying WifiClient instance in the sendRequest.

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

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • 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 Sketch

#include <Arduino.h>

#include <ESP8266WiFi.h>

#include <ESP8266HTTPClient.h>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions