Skip to content

cf-https-connect: fall back from HTTP/3 at the happy eyeballs timeouts - #23238

Closed
nicolas-grekas wants to merge 3 commits into
curl:masterfrom
nicolas-grekas:h3-eyeballs-timeouts
Closed

nicolas-grekas wants to merge 3 commits into
curl:masterfrom
nicolas-grekas:h3-eyeballs-timeouts

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

Since 8.20.0, an HTTP/3 attempt to a host that silently drops UDP, as most firewalls do, falls back to TCP after about one second, whatever --happy-eyeballs-timeout-ms says. 8.19.0 waits 200ms, the hard timeout.

There are two causes, one commit each:

  • since 567803d, nothing re-arms the timer for the hard timeout when the soft one finds that the first attempt has seen data, so the second attempt waits for the next unrelated wakeup: the QUIC retransmission timer
  • a QUIC receive that ends in EAGAIN marks the first byte as received, so an HTTP/3 attempt always looks like it has seen data and the soft timeout never applies to it

With ngtcp2, against a local port that swallows UDP, curl --http3 now falls back after 100ms instead of 990ms. Against a port that answers with junk, it falls back after 200ms instead of 980ms. Each new test_06 case fails without the commit it comes with, and the rest of the pytest suite gives the same results as master here.

When the first attempt has seen data at the soft timeout, nothing armed
a timer for the hard timeout, so the second attempt started on the next
unrelated wakeup only. With HTTP/3 to a host that answers on UDP but
does not complete the handshake, that is the QUIC retransmission timer,
about one second later, whatever the happy eyeballs timeout is.

Follow-up to 567803d curl#21267
A receive call that ends in EAGAIN returns CURLE_OK, which marked the
QUIC connection as having seen data on the first attempt to read. The
soft happy eyeballs timeout then never started the fallback, so a host
silently dropping UDP made HTTP/3 wait for the hard timeout instead.

Follow-up to 5d044ad curl#12678

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The junk-packet test assumes ngtcp2 behavior but currently runs against incompatible HTTP/3 backends.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes HTTP/3-to-TCP fallback timing when UDP traffic is dropped or unproductive.

Changes:

  • Rearms the hard ALPN fallback timer after the soft timeout.
  • Marks QUIC replies only when bytes were received.
  • Adds silent-UDP and junk-response regression tests.
File Description
lib/​cf-https-connect.c Rearms the hard fallback timer.
lib/​vquic/​vquic.c Tracks actual received byte counts.
tests/​http/​test_06_eyeballs.py Tests soft and hard HTTP/3 fallback timing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/http/test_06_eyeballs.py Resolved
…agram timeout test to ngtcp2'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@icing icing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bagder

bagder commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in e634352 Oct 7, 2026
@nicolas-grekas
nicolas-grekas deleted the h3-eyeballs-timeouts branch October 7, 2026 21:26
Comment on lines +108 to +112
try:
_, addr = sock.recvfrom(65536)
sock.sendto(b'\0', addr)
except socket.timeout:
pass

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub's Python checker flagged this as "Empty except".
Is there a way to rewrite that avoids it?

vszakats added a commit that referenced this pull request Oct 14, 2026
@dfandrich

dfandrich commented Nov 3, 2026 via email

Copy link
Copy Markdown
Contributor

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

Labels

Development

Successfully merging this pull request may close these issues.

6 participants