Skip to content

A follow-up to PR 633 - #637

Merged
ivmarkov merged 2 commits into
masterfrom
pr-633
Nov 18, 2026
Merged

ivmarkov merged 2 commits into
masterfrom
pr-633

Conversation

@ivmarkov

Copy link
Copy Markdown
Collaborator

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 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo fmt command to ensure that all changed code is formatted correctly.
  • I have used cargo clippy command to ensure that all changed code passes latest Clippy nightly lints.
  • My changes were added to the CHANGELOG.md of 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 as esp_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:

  • Setting save_client_session on the ESP-IDF configuration now also needs ESP-IDF v5.3 or later. The Kconfig option CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS exists already in ESP-IDF v4.4 to v5.2, but the save_client_session field of esp_http_client_config_t only appeared in v5.3. With an older ESP-IDF and the option enabled, the build would fail.
  • close now resets the state before it checks the result of esp_http_client_close. ESP-IDF resets the client before it closes the socket. So when closing the socket failed, the state stayed at Response, and every following initiate_request tried to flush the old response on the closed socket and failed.
  • A warning is logged when save_client_session is set but the ESP-IDF build does not support it. Before, the setting was ignored silently.
  • The documentation of save_client_session now 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.
  • Shorter documentation and CHANGELOG entries.

Testing

  • The original change was tested on a device by its author (ESP32-P4, ESP-IDF v5.5.5, CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS=y), see HTTP client: TLS session tickets, and closing a connection without dropping the client #633.
  • The changes on top are only type-checked: cargo clippy -p esp-idf-svc -- -Dwarnings for riscv32imc-esp-espidf with ESP-IDF v5.5.5, once with the default configuration and once with CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS=y. They were not built against ESP-IDF v5.2 or older, and not run on a device.

wackazong and others added 2 commits November 13, 2026 23:52
…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.
@ivmarkov
ivmarkov merged commit 4af2950 into master Nov 18, 2026
67 of 68 checks passed
@ivmarkov
ivmarkov deleted the pr-633 branch November 18, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants