-
Notifications
You must be signed in to change notification settings - Fork 7.6k
secureClient.connect(SERVER_DOMAIN, 443) takes long time at handshake. #2041
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
Apart from the question if a timeout is a good idea, did you consider to reuse the connection? See https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/examples/ReuseConnection/ReuseConnection.ino for an example. This keeps the connection open between POSTs and increases the speed (after the first connect) significantly, because connecting, and thus the handshake, is skipped |
@Jeroen88 Thanks. But I am using wifiSecueClient which does not support reuseconnection. |
reuse is handled by HTTP client, independent of the underlying transport provided by WiFiClient(-Secure). You can also send the headers yourself, and handle the (re-)connection yourself, but HTTP Client is far more easy. You could also take a look at my PR #1979, which changes the HTTP Client API (in line with the same changes I did for the ESP8266) to be used more easily with different WiFi clients. Reuse connection should also be supported by your server, but as far as I know, most (all) servers do. |
@a-c-sreedhar-reddy what core version are you using? a similar bug was fix in the end of 2017 About your project design: is it not better to use MQTT? this keeps the connection open for you send and receive data all the time |
@copercini My Esp sdk version is v3.1-dev-661-gf586f5e6 |
After adding a timeout to the WHILE loop it works good. But there is another problem. If at any point secureClient.connect(host, port) returns 0 then all subsequent connects (retries) fail for for many hours. Then connect starts working automatically sometimes or I need to restart the device. Should we be clearing anything in the memory or buffer before we retry? |
it seems that the old connections are not being closed properly, then at some point the memory will run out, causing all these problems (including the timeout issue) Could you print the free memory using |
I am creating wifisecureclient variable in a function and everytime the function exits the destructor is called which closes the connection. |
* issue #2041 * handshake timeout * seconds to milliseconds
Hardware:
Board: ESP32 Dev Module
IDE name: Arduino IDE
Upload Speed: 115200
Computer OS: Windows 10
Description:
I would like to POST data to a server every 10 sec. But after some requests the program enters this loop
in ssl_client.cpp and it never exits.
So is it good to have a timeout for this WHILE loop?
The text was updated successfully, but these errors were encountered: