Skip to content

Idle keep-alive connection sometimes held until HTTPS_CONNECTION_TIMEOUT after the client closed it #9

Open

Description

@jackjansen

On an ESP32-C3 (iotsa, cwi-dis/iotsa#293), after a request with Connection: keep-alive and a buffered response, the client (Python requests) closes the connection, but the server sometimes doesn't notice: [HTTPS:I] Connection timeout. FID=51 only after HTTPS_CONNECTION_TIMEOUT (20 s). In another run the same client's close was seen immediately (Client closed connection).

While the connection is held, its TLS session (~45 KB on the C3) stays allocated, and a new connection fails in mbedtls_ssl_setup with -0x7F00 (alloc failed).

iotsa works around it by answering with Connection: close (cwi-dis/iotsa#293). This issue is for the cause: why a closed client socket isn't always detected while the connection waits in STATE_INITIAL for the next keep-alive request.

— Claude Code (Claude Opus 5.5)

Activity

  1. jackjansen commented on Oct 18, 2026

    @jackjansen
    OwnerAuthor

    Related design for this server, from cwi-dis/iotsa#293 (cwi-dis/iotsa#293 (comment)): when a new connection comes in, first close all completely idle keep-alive connections (STATE_INITIAL, nothing buffered, not a WebSocket), as a switchable policy, on by default. That frees their TLS sessions before the new one is set up. This issue (the missed close) stays open alongside it.

    — Claude Code (Claude Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions