-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Connecting to IPAddress.Any via HTTP/3 #108259
Comments
FYI @BrennanConroy |
Tagging subscribers to this area: @dotnet/ncl |
I expect that problem is that localhost resolves to IPv6 address at the DNS layer var addresses = Dns.GetHostAddresses("localhost");
foreach (var addr in addresses)
{
System.Console.WriteLine(addr);
} prints on my machine
We attempt a connection only via the first IP address returned from Dns.GetHostAddresses runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs Lines 392 to 402 in 042cc95
Related: #82404 A possible workaround can be disabling IPv6, either system-wide, or for .NET only via AppCtx switch or env variable |
Assuming I understand correctly that #82404 tracks (indirectly) making HTTP/3.0 consistent with HTTP/2.0, that answers my question and we can close this issue. Thanks! |
while HTTP 1&2 can connect there is still probably performance penalty for trying IPv6 and falling back to IP4. You should probably investigate @amcasey. As mentioned above HTTP 3 does not have the fall-back at the moment. |
@wfurt Sorry, I'm not following. I agree that reaching ipv4 as a fallback is probably slower than reaching ipv6 directly, but I'm not sure what you want me to investigate. |
can you try packet capture for the case when it seems to work with HTTP 1? e.g. when you bind on |
Sure, though I did provide complete repro steps. 😛 |
yes, this is what I expected. So even if it "works" the setup is not correct IMHO. And the fallback masks the misconfiguration. |
Are you proposing removing the fallback from the socket client? |
no. That is still useful IMHO in general case and it should work for HTTP3 as well at some point. But we should be careful with asp.net docs and examples, perhaps make some explicit comments. We had several cases in the past when people complained about slowness caused by this very issue. |
So the proposed guidance is that, if your server's OS supports ipv6, your server should listen on |
yes, that would be great. It will always work on Windows and since IPv6 is prevalent now it will likely work on most Unixes as well. |
Description
This is more of a question than a bug, so please let me know if this is by design.
We did find #95487 (which points to microsoft/msquic#2704) but, frankly, it was hard to follow and apply to our scenario.
TL;DR: When a (kestrel) server is listening on
IPAddress.Any
,HttpClient
can connect tolocalhost
with HTTP/1.1 and HTTP/2.0, but not with HTTP/3.0. You seem to have to either use127.0.0.1
or switch toIPv6Any
(which also works for 1.1 and 2.0).This seems to happen in both dotnet 8.0 and 9.0.
Reproduction Steps
Server
Client
Expected behavior
Actual behavior
Regression?
Not since 8.0, anyway. Possibly not even a bug.
Known Workarounds
In kestrel, it's more convenient to call
ListenAnyIP
anyway.Configuration
Win11 x64. I appear to have dotnet 8.0.108 and 9.0.100-rc.1.24452.12, though the client may have been using whatever preview of 9.0 is in VS and the server would have been running aspnetcore
main
. I don't believe the specific dotnet versions matter, though the OS might.Other information
No response
The text was updated successfully, but these errors were encountered: