Skip to content
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

Implement SocketsHttpHandler.ConnectCallback #41955

Merged
merged 10 commits into from
Sep 10, 2020

Conversation

geoffkizer
Copy link
Contributor

Fixes #41949

@scalablecory If you could take a look that would be great.

@Dotnet-GitSync-Bot
Copy link
Collaborator

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, to 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.

@ghost
Copy link

ghost commented Sep 8, 2020

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

@geoffkizer geoffkizer added this to the 6.0.0 milestone Sep 8, 2020
@geoffkizer
Copy link
Contributor Author

/azp run runtime-libraries outerloop

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

@geoffkizer
Copy link
Contributor Author

/azp help

@azure-pipelines
Copy link

Supported commands
  • help:
    • Get descriptions, examples and documentation about supported commands
    • Example: help "command_name"
  • list:
    • List all pipelines for this repository using a comment.
    • Example: "list"
  • run:
    • Run all pipelines or specific pipelines for this repository using a comment. Use this command by itself to trigger all related pipelines, or specify specific pipelines to run.
    • Example: "run" or "run pipeline_name, pipeline_name, pipeline_name"
  • where:
    • Report back the Azure DevOps orgs that are related to this repository and org
    • Example: "where"

See additional documentation.

@geoffkizer
Copy link
Contributor Author

/azp list

@geoffkizer
Copy link
Contributor Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@geoffkizer
Copy link
Contributor Author

I pushed changes to react to API review and address feedback above. Please take a look.

@geoffkizer
Copy link
Contributor Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks.

public sealed class SocketsHttpConnectionContext
{
internal SocketsHttpConnectionContext() { }
public DnsEndPoint DnsEndPoint { get { throw null; } }
Copy link
Member

Choose a reason for hiding this comment

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

This may have been discussed in API review. It struck me as a little strange that we dropped the Http from HttpRequestMessage but not the Dns from DnsEndPoint: I'd have expected this to be named EndPoint for consistency. Not a big deal, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't discussed in API review. I think it's fine as it is -- EndPoint is actually the base class of DnsEndPoint, so calling it DnsEndPoint specifically emphasizes that it's a DnsEndPoint and not just any EndPoint.

{
Socket socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);
socket.NoDelay = true;
socket.DualMode = true;
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the OS doesn't support IPv6? I'm wondering if this should instead use the 2-arg ctor:

var socket = new Socket(SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just transferring over the existing code from SocketsConnectionFactory. But I agree, it seems a bit questionable.

@scalablecory Do you know why SocketsConnectionFactory was doing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to change this as @stephentoub suggested. @scalablecory if you have any thoughts here, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

was likely a bug.

Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Bind(new IPEndPoint(IPAddress.Loopback, 0));
await s.ConnectAsync(context.DnsEndPoint, token);
s.NoDelay = true;
Copy link
Member

Choose a reason for hiding this comment

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

One of the other commonly discussed use cases is tweaking keep alive settings on the socket. Just for completeness, might be worth adding a test around that, too, even though it's unlikely to flag something this test doesn't.

@geoffkizer
Copy link
Contributor Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@scalablecory scalablecory left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +11 to +12
private readonly DnsEndPoint _dnsEndPoint;
private readonly HttpRequestMessage _requestMessage;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: these could be auto props.

@geoffkizer geoffkizer merged commit 8b8c390 into dotnet:master Sep 10, 2020
@geoffkizer
Copy link
Contributor Author

/backport to release/5.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/5.0-rc2: https://github.com/dotnet/runtime/actions/runs/248358609

Sign up for free to 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.

Add SocketsHttpHandler.ConnectCallback
7 participants