Runtime: Add implementation for SetTcpKeepAlive in ServicePoint

Created on 21 Dec 2017  路  8Comments  路  Source: dotnet/runtime

Hi

I am porting my .NetFramework project to .NetStd 2.0.

I have long running workloads. I need to set Tcp Keep-Alive messages. This is supported in .NetFramework.
Its implementation in corefx is not doing anything after validation.
https://github.com/dotnet/corefx/blob/master/src/System.Net.ServicePoint/src/System/Net/ServicePoint.cs#L101

Hence, my HttpClient Api calls don't send tcp keep alive messages.

Is there any workaround ?
When can we expect full implementation of SetTcpKeepAlive ?

area-System.Net enhancement

Most helpful comment

If you need it now - I did a backport of SocketsHttpHandler to .NET Standard 2.0 and added a SocketCreated event that allows you to configure TCP Keepalive on the socket, it's on NuGet / GitHub.

I also ported the Microsoft tests for your peace of mind.

All 8 comments

It's 2019 now. Any updated plans for this? Any alternative?

It's in Future milestone. The top post does not have any upvotes (please add yours if you need it).
Overall, not enough to fund it anytime soon - we have higher-impact problems to solve in networking area.

ping. @karelz
Is there any workaround/alternative ? any other library ? anything ?

It is now exposed on Sockets - see dotnet/runtime#24041
We do not have it exposed on Http stack yet AFAIK. The priority is low given the small demand.

My use case : Azure Load Balancer terminates the http requests that are longer than 4 minutes if httpclient does not send TCP-keep alive packets.

We do not have it exposed on Http stack yet AFAIK. The priority is low given the small demand.

FWIW, my preference would be to expose this capability via something like https://github.com/dotnet/corefx/issues/23426#issuecomment-421627596, i.e. add a callback to SocketsHttpHandler that either provides the created Socket to a callback or invokes a method to create the Socket, such that a callback can manipulate the Socket however it likes, including calling the APIs @karelz mentions to configure keepalive.

Triage: We think there is another dupe of this - more general as @stephentoub describes above.

If you need it now - I did a backport of SocketsHttpHandler to .NET Standard 2.0 and added a SocketCreated event that allows you to configure TCP Keepalive on the socket, it's on NuGet / GitHub.

I also ported the Microsoft tests for your peace of mind.

Was this page helpful?
0 / 5 - 0 ratings