Skip to content

Additional QuicConnectionOptions - #94211

Merged
rzikm merged 8 commits into
dotnet:mainfrom
rzikm:72984-API-Proposal-Additional-QuicConnectionOptions
Nov 29, 2023
Merged

Additional QuicConnectionOptions#94211
rzikm merged 8 commits into
dotnet:mainfrom
rzikm:72984-API-Proposal-Additional-QuicConnectionOptions

Conversation

@rzikm

@rzikmrzikm commented Oct 31, 2023

Copy link
Copy Markdown
Member

Closes#72984.
Closes#70090.

Adds:

  • KeepAliveInterval - sending ping frames to prevent the connection from idling out. (we may want to add the same property on QuicConnection itself so that users can turn pings on/off according to their needs)
  • flow-control limits (max_data) - stream-level limits will have effect only with newer MsQuic having Support setting flow control limits for individual stream types microsoft/msquic#3948. 2.4+ should be it
  • HandshakeTimeout - kills the connection if the handshake is not established in the given amount of time
    • ServerOptionsCallback still has 10s timeout as before, once the callback returns, the timeout value from the options is applied.
      The client times out as well.
    • Timeouts lead to peer receiving UserCanceled TLS Alert which is weird but is not against the spec, although getting CONNECTION_CLOSE with APPLICATION_ERROR would be more expected.

Other improvements:

  • if the client terminates the connection during the handshake, CancellationToken passed to ServerOptionsCallback fires as well.
  • Fix property names in ArgumentExceptions thrown from connection options validation (previously it put the message instead of the parameter name)

@ghost

Copy link
Copy Markdown

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghostghost assigned rzikmOct 31, 2023
@ghost

Copy link
Copy Markdown

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Closes #72984.

Draft for now until we go through API review.

Author:rzikm
Assignees:-
Labels:

new-api-needs-documentation, area-System.Net.Quic

Milestone:-

@rzikm
rzikmforce-pushed the 72984-API-Proposal-Additional-QuicConnectionOptions branch from 8791161 to 96dccbfCompareNovember 15, 2023 12:42

@ManickaPManickaP left a comment

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.

I know it's a draft, but I might not have time to review this properly later.

Comment threadsrc/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnectionOptions.cs Outdated
Comment threadsrc/libraries/System.Net.Quic/src/System/Net/Quic/QuicListener.cs Outdated
Comment threadsrc/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnectionOptions.cs Outdated
Comment threadsrc/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs Outdated
@rzikm
rzikm marked this pull request as ready for review November 16, 2023 14:27
@rzikm
rzikm requested a review from a teamNovember 16, 2023 14:27
@rzikm

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

private readonly ValueTaskSource _connectedTcs = new ValueTaskSource();
private readonly ValueTaskSource _shutdownTcs = new ValueTaskSource();

private readonly CancellationTokenSource _shutdownCancellationTokenSource = new CancellationTokenSource();

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.

I think we might need to dispose _shutdownCancellationTokenSource?
Also, the naming confuses me... It implies the cancellation of the connection's shutdown, but it's not, it's for cancelling the handshake in the Listener, right? (and it also means it's not needed on the client side?)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It is used only for listener to cancel the connection options callback if peer closes the connection before the handshake. I did not find a way to put the CTS outside QuicConnection.

I will try to come up with a better name

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.

What do we do in SslStream case? Do we also react and cancel user callback when the client kills handshake in the meantime?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

With sslstream we don't check for client-side activity while invoking the callback. We would have to always have a pending read on the inner stream and check for errors there. SslStream passes in the same token as to AuthenticateAsClientAsync.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Renamed to ConnectionShutdownToken and added a comment

@ManickaPManickaP left a comment

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.

In general looks good. I think the last contentious thing is the _shutdownCancellationTokenSource.

Exception exception = await AssertThrowsQuicExceptionAsync(QuicError.ConnectionTimeout, async () => await listener.AcceptConnectionAsync());
Assert.Equal(SR.Format(SR.net_quic_handshake_timeout, QuicDefaults.HandshakeTimeout), exception.Message);
QuicClientConnectionOptions clientOptions = CreateQuicClientOptions(listener.LocalEndPoint);
clientOptions.HandshakeTimeout = clientShorterTimeout ? TimeSpan.FromSeconds(2) : TimeSpan.FromSeconds(20);

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.

I'm pretty sure this will eventually pop-up in CI report. Especially if you're asserting specific types of exception that should happen only in certain order of events depending on this timing.

But we can wait until we see it.

private readonly ValueTaskSource _connectedTcs = new ValueTaskSource();
private readonly ValueTaskSource _shutdownTcs = new ValueTaskSource();

private readonly CancellationTokenSource _shutdownCancellationTokenSource = new CancellationTokenSource();

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.

What do we do in SslStream case? Do we also react and cancel user callback when the client kills handshake in the meantime?

@ManickaPManickaP left a comment

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.

:shipit:
Thank you!

@rzikm

Copy link
Copy Markdown
MemberAuthor

All CI failures are known build failures

@ManickaP

Copy link
Copy Markdown
Member

BTW, I assume this also fixes #70090

@CarnaViireCarnaViire left a comment

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.

LGTM, thanks

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API Proposal]: Additional QuicConnectionOptions [API Proposal]: Quic connection keep alive

4 participants

@rzikm@ManickaP@CarnaViire@karelz