Skip to content

time_connect and remote_ip lost when the connect timeout fires during the TLS handshake (regression in 8.11.0) #23318

Closed

Description

@jarthod

I did this

Using nc here as a server that accepts the TCP connection but never answers the ClientHello:

> nc -lk 127.0.0.1 9999

> curl -vk -o /dev/null --connect-timeout 1 -w 'time_connect: %{time_connect}\nremote_ip: %{remote_ip}\n' https://127.0.0.1:9999/
*   Trying 127.0.0.1:9999...
* ALPN: curl offers http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* SSL Trust: peer verification disabled
* Connection timed out after 1001 milliseconds
* closing connection #0
curl: (28) Connection timed out after 1001 milliseconds
time_connect: 0.000000
remote_ip:

I expected the following

I expected time_connect and remote_ip to be present.
The same happens with a real remote host when the timeout runs out during the handshake.

The TCP connection was established, so time_connect and remote_ip should be set. That's what versions before 8.11.0 did (8.5.0 output):

curl: (28) SSL connection timeout
time_connect: 0.000090
remote_ip: 127.0.0.1

I use this in my monitoring service to tell a TCP connect timeout apart from a TLS handshake timeout, to measure TCP connection time, and to show the IP that was used. Since 8.11.0 the two cases look identical and the connection time and IP are gone.

I bisected the time_connect "regression" to 2338687 ("multi: make multi_handle_timeout use the connect timeout", #15119) but after reading the PR and code diff I don't really understand better 🫠 if this side-effect is know/intentional or if it's a regression. Current master still has this behaviour.

I also bisected the remote_ip "regression" to another anoter commit: ea6f5c9, "connect: limit update IP info" (#14699), this one looks more intentional but the happy eyeballs issue is not longer present once TCP connection is established. So I would still expect the IP to be present after a successful TCP connection, but I also understand this might be tricky to handle all those cases ^^ I also read about "CF_QUERY_IP_INFO" in the PR but couldn't find any doc how to use this flag and what it does. If the new normal is that the IP in CURLINFO_PRIMARY_IP will only be present after successful TLS handhsake, maybe we should update the doc a bit then, and provide some alternative like CF_QUERY_IP_INFO if relevant.

Thanks!

curl/libcurl version

Reproduced in curl 8.23.0-DEV (Linux) libcurl/8.23.0-DEV OpenSSL/3.5.5 zlib/1.3.1
First discovered in curl 8.18.0 and before that I used curl 8.5.0 without this problem

operating system

Ubuntu 26.04 LTS, Linux 7.0.0 x86_64 (and Ubuntu 24.04)

Activity

  1. added 3 commits that reference this issue on Oct 8, 2026
    765b7dd
    162d3ab
    74f4b2f
  2. R1patil commented on Oct 9, 2026

    @R1patil

    Hi, I'd like to investigate this issue and work on a fix. I plan to reproduce the regression, review the connection and timeout handling, and add a regression test. Is anyone currently working on this, and would a contribution be welcome?

  3. icing commented on Oct 9, 2026

    @icing
    Contributor

    Could you check if #23319 helps here?

  4. jarthod commented on Oct 9, 2026

    @jarthod
    SponsorAuthor

    That was quick 🚀 thanks 👍
    I just compiled master with the fix and confirmed the connect time and IP are now present.
    While testing this master version I also found another unrelated timing issue which I'm going to report in another ticket.

  5. added a commit that references this issue on Oct 9, 2026
    354834b
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