Skip to content

WifClientSecure breaking on ESP8266? #892

Open
@mooomooo

Description

@mooomooo

MWE: Starting from the example sketch in https://github.com/Links2004/arduinoWebSockets/blob/master/examples/esp8266_pico/WebSocketClientSSL/WebSocketClientSSL.ino, which works fine, I add a new function:

const char* url = "https://www.howsmyssl.com/a/check";

void https() {
    WiFiClientSecure client;
    HTTPClient https;
    client.setInsecure();
    int checkBegin = https.begin(client, url);
    int code = https.GET();
    String payload = https.getString();
    USE_SERIAL.printf("!!!  Begin = %d, code = %d, payload:", checkBegin, code);
    USE_SERIAL.println(payload);
    https.end();
    client.stop();
}

Whenever I call this function before any calls to webSocket.loop(); it successfully connects and prints the payload. However, anytime afterwards, it fails to connect with the debug log:

[HTTP-Client][begin] url: https://www.howsmyssl.com/a/check
[HTTP-Client][begin] host: www.howsmyssl.com port: 443 url: /a/check
[HTTP-Client][sendRequest] type: 'GET' redirCount: 0
[HTTP-Client] failed connect to www.howsmyssl.com:443
[HTTP-Client][returnError] error(-1): connection failed
[HTTP-Client][end] tcp is closed
!!!  Begin = 1, code = -1, payload:
[HTTP-Client][end] tcp is closed

Somehow, the websockets library is preventing any further SSL connections? Notably, this isn't a problem with subsequent http requests using WiFiClient (i.e. not Secure). This issue also does not show up on ESP32 (i.e. it works as expected).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions