Skip to content

Detect name resolution errors in QuicConnection.ConnectAsync #89095

Closed

Activity

  1. added this to the 8.0.0 milestone on Jul 18, 2023
  2. self-assigned this
    on Jul 18, 2023
  3. changed the title [-][HttpRequestError] Map QUIC errors to HttpRequestError if possible[/-] [+][HttpRequestError] Detect NameResolutionError with Quic[/+] on Aug 2, 2023
  4. antonfirsov commented on Aug 2, 2023

    @antonfirsov
    ContributorAuthor

    Thinking that QuicException.TransportErrorCode would help identifying relevant error cases was a wrong assumption.

    The actual problem here, similarly to #89096 is that we can't detect NameResolutionError. If QuicClientConnectionOptions.ClientAuthenticationOptions.TargetHost is different than the actual host, FinishConnectAsync will resolve the addresses, and in case it fails a SocketException(SocketError.HostNotFound) will correctly surface to the user. But this is not the case with HTTP/3 logic where we have host == QuicClientConnectionOptions.ClientAuthenticationOptions.TargetHost. In this case we leave the leave the name resolution to msquic, which will fail with the mysterious error code -2147013895 (0x80072af9) on Windows and QUIC_STATUS_INVALID_PARAMETER on Linux.

    Quic repro
    DnsEndPoint endPoint = new DnsEndPoint("BadHost", 443);
    
    await Assert.ThrowsAsync<SocketException>(async () => await QuicConnection.ConnectAsync(new QuicClientConnectionOptions()
    {
        MaxInboundBidirectionalStreams = 0,
        MaxInboundUnidirectionalStreams = 5,
        IdleTimeout = TimeSpan.FromMinutes(1),
        DefaultStreamErrorCode = 0x10c,
        DefaultCloseErrorCode = 0x100,
        RemoteEndPoint = endPoint,
        ClientAuthenticationOptions = new SslClientAuthenticationOptions()
        {
            TargetHost = "BadHost",
            EnabledSslProtocols = SslProtocols.Tls13,
            ApplicationProtocols = new Collections.Generic.List<SslApplicationProtocol> { SslApplicationProtocol.Http3 }
        }
    }));

    A robust fix would be to do the name resolution in S.N.Quic code, running a multi-connect attempt similar to Socket.'s DnsConnectAsync. Since there is no multi-connect in msquic anyways (microsoft/msquic#1181), it might be good enough to also take the first resolved address for the host == TargetHost case.

    cc @karelz @ManickaP @CarnaViire, not sure how critical is this for 8.0, you may want to punt this.

  5. changed the title [-][HttpRequestError] Detect NameResolutionError with Quic[/-] [+]Detect name resolution errors in QuicConnection.ConnectAsync[/+] on Aug 2, 2023
  6. ManickaP commented on Aug 3, 2023

    @ManickaP
    Member

    Seems like dupe of #82404

  7. antonfirsov commented on Aug 3, 2023

    @antonfirsov
    ContributorAuthor

    Sorry, I forgot about that one. In case we want a simple fix for the HttpRequestError problem, I wonder if we can get rid of the host.Equals(options.ClientAuthenticationOptions.TargetHost) special-casing, always resolving the name & setting a QUIC_PARAM_CONN_REMOTE_ADDRESS to the first address? Or do we expect problematic side-effects from doing so? If we are unwilling to do such a change for 8.0, let's close this issue as a dupe of #82404.

  8. ManickaP commented on Aug 3, 2023

    @ManickaP
    Member

    Yeah, I think we could do that, i.e. remove that part of the condition and do name resolution ourselves. I see no problem with that. @wfurt, just checking if you see any potential issues with that? If not, Anton go ahead.

  9. self-assigned this
    on Aug 3, 2023
  10. antonfirsov commented on Aug 3, 2023

    @antonfirsov
    ContributorAuthor

    Tentatively re-assigned myself. Will bring it up in todays meeting, and file a PR if we have consensus. (If no, let's close it as a dupe.)

  11. wfurt commented on Aug 3, 2023

    @wfurt
    Member

    I think that should be ok. It is more work but we do it anyway and it possibly opens avenue to deal better with names that remove to multiple addresses.

  12. ghost added
    in-pr
    on Aug 3, 2023
  13. ghost removed
    in-pr
    on Aug 4, 2023
  14. ghost locked as resolved and limited conversation to collaborators on Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions