Skip to content

HTTP/3 with IPv6 #2911

@anuraaga

Description

@anuraaga

When trying out HTTP/3 support, I noticed on a typical macOS laptop, that it seems IPv6 is used even when configuring the client to IPv4. Following the advice in #584, to force IPv4

builder = builder
      .http3_prior_knowledge()
      .local_address(IpAddr::from([0, 0, 0, 0]));

It seems to still try IPv6 and fail hard. Presumably it should be using IPv4 from the beginning.

E       RuntimeError: Request failed: error sending request for url (https://localhost:8081/echo): error sending request: invalid remote address: [::1]:8081

Besides that, if not forcing IPv4 like that, when issuing a request to localhost, it will first try IPv6 before IPv4. This should generally be fine but AFAICT, on macOS IPv6 can't be used with quic - when trying with curl --http3, I get the below output which confirms it tries with IPv6 and quickly falls back to IPv4. This is not noticable. However, when using reqwest, it seems to finally succeed after 30s - I'm guessing there is a 30s timeout on trying to connect with IPv6 before falling back to IPv4 and succeeding. If I change the URL to 127.0.0.1, no issues - I guess the IPv6 -> v4 fallback has to be configured somehow to fail faster.

* Host localhost:8081 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8081...
* SSL Trust: peer verification disabled
* QUIC: connection to ::1 port 8081 refused
* QUIC connect to ::1 port 8081 failed: Could not connect to server
*   Trying 127.0.0.1:8081...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-http3Area: HTTP/3E-pr-welcomeThe feature is welcome to be added, instruction should be found in the issue.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions