-
Notifications
You must be signed in to change notification settings - Fork 13.3k
HTTP SSL client hangs when an access point goes down #5786
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
Comments
I made a simpler example, which works in 2.4.2 #include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
const char *host = "35.237.110.54";
const char *url = "/test/";
const int httpsPort = 443;
const char *fingerprint = "26 24 FA 2B 26 1D DD 1F 2F 12 68 7C 19 49 13 DF D3 8A 7D 65";
bool httpTest() {
WiFiClientSecure client;
client.allowSelfSignedCerts();
if (client.connect(host, httpsPort)) {
Serial.println("connection OK");
} else {
Serial.println("connection failed");
return false;
}
if (client.verify(fingerprint, host)) {
Serial.println("certificate matches");
} else {
Serial.println("certificate doesn't match");
}
Serial.print("requesting URL: ");
Serial.println(url);
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"User-Agent: BuildFailureDetectorESP8266\r\n" +
"Connection: close\r\n\r\n");
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
String line = client.readStringUntil('\n');
Serial.println("reply:");
Serial.println(line);
Serial.println("");
}
void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
while (!Serial)
yield();
WiFi.begin();
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
httpTest();
} else {
Serial.println("Not connected");
}
} It works perfectly in 2.4.2 when I turn off my access point:
But when I use 2.5.0 I found the same issue:
stack trace:
|
I experienced the same (or at least a very similar) issue with SW WDT resets when the WiFi connection is lost during the client.connect() call. Connecting to an url with a long response time generated this issue on a regular base. After quite a lot of testing, I was able to narrow down the root cause of my crashes to the WiFi loss during a WiFiClientSecure connection. I did not double-check if a WiFiClient connection is affected as well.
With core revision
and the decoded exception is
It's interesting to note that using the current head revision as of today
|
Hi, |
Please try the latest GIT head. #6065 included a fix that enables a fst SSL disconnect response and, I think, will error out quickly and not hang. Please report back so we can track. |
The fix seems to be effective for the case "WiFi disconnects while SSL-connect is ongoing", I do no longer observe SW WDT resets. Using version
The git head revision does no longer show the SW WDT resets since around begin of May. I used this sketch for reproducing the issue and testing the fix. A ticker disconnects the WiFi while the SSL-connect is ongoing.
|
I found an interesting bug causing hang of WiFiClient and WiFiClientSecure which could be related - see #6104. |
Many many thanks, that solution works like a charm. I've been fighting this for weeks. Have made a workaround, but this solved my problem. I believe it can help many more people. |
All credit goes to @sislakd for this specific fix. I'll close this bug for now since it seems to have multiple confirmations. |
Platform
Settings in IDE
Problem Description
I see a constant Soft WDT reset/wdt reset when I am using HTTP SSL client and I turn off my access point.
Below code can work hours, but if I turn my access point, then ESP8266 hangs.
The issue is not reproducible if uncomment the 6 line:
MCVE Sketch
Debug Messages
Decoding stack results
The text was updated successfully, but these errors were encountered: