Skip to content

Connection reuse not working for HTTP3 connections #14890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mackenzie-remote opened this issue Sep 13, 2024 · 6 comments
Closed

Connection reuse not working for HTTP3 connections #14890

mackenzie-remote opened this issue Sep 13, 2024 · 6 comments
Assignees
Labels
HTTP/3 h3 or quic related

Comments

@mackenzie-remote
Copy link
Contributor

I did this

When I use a version of curl that supports HTTP3, and uses the alt-svc cache file, domains that do have h3 enabled don't seem to do connection reuse, where-as if I connect to h2 the connection is reused.

Example curl.config file:

url = "https://www.youtube.com/feeds/videos.xml?channel_id=UCC8VtutLDSrreNEZj8CU01A"
output = /dev/null
next
url = "https://www.youtube.com/feeds/videos.xml?channel_id=UC7_VGkwCoKfqh1eZEkzey3A"
output = /dev/null

curl --alt-svc alt-svc.txt -v -K curl.config

The first time (with verbose) and an empty alt-svc, I can see this log message between the first and second transfer:

* Re-using existing connection with host www.youtube.com

When running curl a second time with a populated alt-svc cache it connects using hhttp3 and it does not say 'Re-using existing connection' but

* Connected to www.youtube.com () port 443

(and I verified that it wasn't just a logging issue - when I ran tcpdump I could see that it was opening a new udp connection with a different source port).

I expected the following

For subsequent connections are reused to the same host when using http3.

curl/libcurl version

curl 8.10.0 (aarch64-apple-darwin) libcurl/8.10.0 OpenSSL/3.3.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 c-ares/1.33.1 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.63.0 nghttp3/1.5.0
Release-Date: 2024-09-11
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP TrackMemory UnixSockets zstd

operating system

Darwin xx 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64

@vszakats vszakats added the HTTP/3 h3 or quic related label Sep 13, 2024
@icing icing self-assigned this Sep 17, 2024
@icing
Copy link
Contributor

icing commented Sep 17, 2024

@mackenzie-remote can you provide us a curl trace of such a situation? Please invoke curl with curl -v --trace-config=ids,time,http/3. That should give us an idea what is going on. Thanks!

@mackenzie-remote
Copy link
Contributor Author

mackenzie-remote commented Sep 18, 2024

OK that's annoying. I can't replicate the issue on Darwin, but I can replicate it on Linux.

Binaries built by this project https://github.com/stunnel/static-curl at
https://github.com/stunnel/static-curl/releases/download/8.10.1/curl-linux-aarch64-8.10.1.tar.xz

curl version:
curl 8.10.1 (aarch64-pc-linux-gnu) libcurl/8.10.1 OpenSSL/3.3.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 c-ares/1.33.1 libidn2/2.3.7 libpsl/0.21.5 libssh2/1.11.0 nghttp2/1.63.0 nghttp3/1.5.0
Release-Date: 2024-09-18
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP TrackMemory UnixSockets zstd

OS version:
Linux xx 6.5.0-1021-oracle #21~22.04.1-Ubuntu SMP Fri Apr 5 20:30:17 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Logs attached as requested with -v --trace-config ids,time,http/3

File 1 is first run with no alt-svc.txt
File 2 is the second run with alt-svc.txt as follows:

# Your alt-svc cache. https://curl.se/docs/alt-svc.html
# This file was generated by libcurl! Edit at your own risk.
h2 www.youtube.com 443 h3 www.youtube.com 443 "20241018 21:52:04" 0 0
h3 www.youtube.com 443 h3 www.youtube.com 443 "20241018 21:52:10" 0 0

issue14890-8.10.1-trace-1.log
issue14890-8.10.1-trace-2.log

@icing
Copy link
Contributor

icing commented Sep 19, 2024

Thanks. I have reproduced in a local test case that the first url's connection is indeed not reused, but should have been. Investigating...

icing added a commit to icing/curl that referenced this issue Sep 19, 2024
- When searching for existing connections, interpret the
  default CURL_HTTP_VERSION_2TLS as "anything goes". This
  will allow us to reuse HTTP/3 connections better
- add 'http/1.1' as allowed protocol identifier in Alt-Svc
  files
- add test_02_0[345] for testing protocol selection on
  provided alt-svc files

refs curl#14890
@icing
Copy link
Contributor

icing commented Sep 19, 2024

Found the problem. HTTP/3 connections were not reused when the transfer had no specific requirements. This led to your second request to open a new connection.

Should be fixed in #14966.

@mackenzie-remote
Copy link
Contributor Author

Thanks, am trying to build that locally to test the fixed branch.. Will report back.

@mackenzie-remote
Copy link
Contributor Author

That fixed the issue, thank you again @icing!

Happy log expert from the second run showing it re-using the existing HTTP/3 connection:

12:29:42.607193 [0-0] * [HTTP/3] [0] easy handle is done
12:29:42.607222 [0-0] * Connection #0 to host www.youtube.com left intact
12:29:42.607807 [1-0] * [HTTP/3] negotiated idle timeout: 120000ms
12:29:42.607842 [1-0] * Re-using existing connection with host www.youtube.com

bagder pushed a commit that referenced this issue Sep 20, 2024
- When searching for existing connections, interpret the
  default CURL_HTTP_VERSION_2TLS as "anything goes". This
  will allow us to reuse HTTP/3 connections better
- add 'http/1.1' as allowed protocol identifier in Alt-Svc
  files
- add test_02_0[345] for testing protocol selection on
  provided alt-svc files

Fixes #14890
Reported-by: MacKenzie
Closes #14966
pps83 pushed a commit to pps83/curl that referenced this issue Apr 26, 2025
- When searching for existing connections, interpret the
  default CURL_HTTP_VERSION_2TLS as "anything goes". This
  will allow us to reuse HTTP/3 connections better
- add 'http/1.1' as allowed protocol identifier in Alt-Svc
  files
- add test_02_0[345] for testing protocol selection on
  provided alt-svc files

Fixes curl#14890
Reported-by: MacKenzie
Closes curl#14966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP/3 h3 or quic related
Development

No branches or pull requests

3 participants