Repository navigation
Conversation
…opping the client `Configuration::save_client_session` passes `esp_http_client_config_t::save_client_session` (needs `CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS`): the client keeps the TLS session ticket of a connection and resumes the session on the next connection to the same host. `EspHttpConnection::close` calls `esp_http_client_close`: the connection to the server goes, the client with its buffers, configuration and saved ticket stays, so an application that keeps clients per host can close their connections (e.g. before switching the radio off) and still get the resumed handshake on the next request. On an ESP32-P4 a full TLS 1.2 handshake took about 1.5 s; the resumed one is a round trip.
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo fmtcommand to ensure that all changed code is formatted correctly.cargo clippycommand to ensure that all changed code passes latest Clippy nightly lints.CHANGELOG.mdof the affected crate(s) in the proper section.Pull Request Details 📖
Description
This is #633 by @wackazong, with a few changes on top. Their commit is kept as it is, and the changes are in a separate commit. Supersedes #633.
#633 adds two things to the HTTP client:
Configuration::save_client_session, which is passed to ESP-IDF asesp_http_client_config_t::save_client_session. With it, the client saves the TLS session ticket and resumes the session on the next connection, instead of doing a full handshake.EspHttpConnection::close, which closes the connection to the server but keeps the client, together with its saved ticket.Changes on top of #633:
save_client_sessionon the ESP-IDF configuration now also needs ESP-IDF v5.3 or later. The Kconfig optionCONFIG_ESP_TLS_CLIENT_SESSION_TICKETSexists already in ESP-IDF v4.4 to v5.2, but thesave_client_sessionfield ofesp_http_client_config_tonly appeared in v5.3. With an older ESP-IDF and the option enabled, the build would fail.closenow resets the state before it checks the result ofesp_http_client_close. ESP-IDF resets the client before it closes the socket. So when closing the socket failed, the state stayed atResponse, and every followinginitiate_requesttried to flush the old response on the closed socket and failed.save_client_sessionis set but the ESP-IDF build does not support it. Before, the setting was ignored silently.save_client_sessionnow says that ESP-IDF keeps one ticket per client, and offers it to whatever host the client connects to next. So the option is meant for a client per host. Normally another host just declines the ticket, and a full handshake follows.Testing
CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS=y), see HTTP client: TLS session tickets, and closing a connection without dropping the client #633.cargo clippy -p esp-idf-svc -- -Dwarningsforriscv32imc-esp-espidfwith ESP-IDF v5.5.5, once with the default configuration and once withCONFIG_ESP_TLS_CLIENT_SESSION_TICKETS=y. They were not built against ESP-IDF v5.2 or older, and not run on a device.