-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
WiFiClientSecure.connect crash after several POST requests #4569
Comments
I see something like this as well. A few WiFiClientSecure request go through but 3rd or 4th one I see the same error as you. If I convert the server to not use SSL, WiFiClient sends same data without issues. Usually you will be asked to enable "SSL" debugging in Arduino IDE and post debugging results here as well. |
Same here. |
@telliottosceola |
Hi @jo-russ |
I can confirm some kind of memory leak, even with latest git version ( as there was a similar issue with WiFiClient fixed versus 2.4 at 95b1348 ). I observe a leakage of around 100B per request, which adds up to @telliottosceola reported crash after 100-200 requests. I will have a look and report in case Im able to get more information. |
@telliottosceola Can't see anything out of ordinary. The only difference I see from what I have is "Connection: close" header in request and httpsPort as "const int" |
@earlephilhower tried the new latest git version as well, still its crashing after several requests. |
(looks like I posted this in the PR and not the issue before, reposting) I'm not seeing any leak per connection using a modified version of the script posted at the top here (to point to my public web server, and do GET instead of POST, but nothing materially different). I'm running with debug level "None", not even the larger mem free option of NoAssert+NDEBUG///
Mem free stabilized at 31056 bytes after 2 or 3 cycles and is now at ~400 loops without any change.
|
it just crashed after 288 request. `{"result":"on"} Content-Type: application/json; charset=utf-8 Connection: close Status: 200 OK Cache-Control: no-cache, no-store Strict-Transport-Security: max-age=15552000; includeSubDomains Pragma: no-cache X-XSS-Protection: 1; mode=block X-Request-Id: f5999b09-d58b-4a9f-b364-1e9de325ceeb X-Runtime: 0.005893 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Thu, 12 Apr 2018 15:52:36 GMT X-Powered-By: Phusion Passenger 5.1.4 Server: nginx/1.10.3 + Phusion Passenger 5.1.4 ` `{"result":"on"} Content-Type: application/json; charset=utf-8 Connection: close Status: 200 OK Cache-Control: no-cache, no-store Strict-Transport-Security: max-age=15552000; includeSubDomains Pragma: no-cache X-XSS-Protection: 1; mode=block X-Request-Id: dff3c8ca-0f61-41fc-b384-de8a4c2935d2 X-Runtime: 0.007524 X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff Expires: Fri, 01 Jan 1990 00:00:00 GMT Date: Thu, 12 Apr 2018 15:58:57 GMT X-Powered-By: Phusion Passenger 5.1.4 Server: nginx/1.10.3 + Phusion Passenger 5.1.4` |
I'm running the same test here as well. I slightly modified the code so the http response does not print to the serial monitor(just commented out Serial.println(line);
Serial monitor log thus far
|
Also @earlephilhower I want to say thank you very much for your input thus far. You are more than welcome to run a test using the exact code I have posted above so it makes post requests to our server. This way you can run a test identical to ours. Only difference would be your hardware. I would be very curious to see if you see the same small memory leak we are seeing. |
Your first 2 lines say what's happening:
So the For a quick fix I suggest moving the WiFiClientSecure object into the loop() context which should ensure it's closed at the end of a loop (or calling |
Hi @earlephilhower
And here's the the serial monitor log:
|
Just cleaned up the code and removed everything that was not required. Here is the minimal code that works successfully:
And the serial monitor log:
|
Well... After letting the code run for a bit I found that I am loosing 48 bytes from heap memory "every once in a while". It does not happen after a consistent number of requests it seems to be random at the moment. In this test the first time memory was lost was after the first 32 requests, so the programmer in me quickly scrolled down to the 64th request expecting to find loss in memory there as well but no memory had been lost at that point. The next time 48 bytes were lost from heap was after request 158. Then there was a loss at 210, another at 225, another at 267, etc. Now this is a vast improvement from before but if the module is loosing heap memory then eventually it WILL crash. I just added client.stop at the end of the loop and will let that run now for testing. So far it lost 48 bytes of memory after request number 5 so I am still seeing it. Somehow 48 bytes are not being freed. Other than declaring the WiFiClientSecure object in the loop so it leaves scope every cycle to free memory and calling client.stop at the end of the loop for good measure is there anything else you can think I should try? If you want me to post most recent code update please let me know and I'll be happy to. |
I'm on git head (well, git head as of 2-3 days ago) but I'm unable to make your original test app lose memory now, connecting to your server. Can you verify that it fails consistently for you? I see ~22KB (22136) free on each loop, with the # constant for loops 2-13. All I did was update the fingerprint, which I guess changed since your original posting. I was also unable to see a memory leak when I took the last code and moved the WiFiClientSecure out to globals and off the stack. There will be +/- a few bytes, unrelated to the WiFiClient*, simply due to LWIP and it's connection cache/received buffers. If you can leave your app running and capture the free over a longer period (maybe let it try overnight, capture Serial output to a file, but at least 15mins or so) that would help to see if it's really lost or a temporary thing. I also edited your last code sample to remove your WiFi password. |
Using 2.4.1 - Can any one help me what should i do, because WiFiClientSecure client Before connecting to https urlFree heap:- 32304 Just After 1st connection with https urlFree heap:- 18088 After 2nd connection with https urlFree heap:- 37152 After 3rd connection with https urlFree heap:- 37152 Code to display head and stackSerial.print ("Free heap:- "); Exception Stack Trace DecoderException 29: StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores |
@sumitkumarjaiswal |
BearSSL is merged in #4273 , with alternate BearSSL::WiFi* classes. Although axtls-based classes are still available and even the default, they are planned for deprecation and then retirement, hence won't be fixed. Any issues with BearSSL-based classes should be reported in new issues. |
I have an application where post requests are made to an HTTPS server repeatedly. After several requests, generally 100-200 or so my application crashes. I have debugging enabled for SSL so I can see what is going on there. It seems to crash right after Server Hello Done(14) every time. I have also Decoded the exception. Here is my code which I have simplified as much as possible:
Here is the decoded Exception on crash:
Here is the log on the last successful transmission and the subsequent transmission after that which crashed:
Any insight into the possible causes of these crashes would be greatly appreciated. I just cannot imagine what is causing these crashes.
The text was updated successfully, but these errors were encountered: