ServicePointManager.FindServicePoint is obsolete in .NET 6

159 Views Asked by At

Starting in .Net6, ServicePointManager.FindServicePoint is obsolete and should not be used.

However, I am using this ServicePoint to log some metadata about my service during a failing case

var servicePoint = ServicePointManager.FindServicePoint(request.RequestUri);
LogWarning(
    $"active connections = {servicePoint.CurrentConnections}/{servicePoint.ConnectionLimit}, " +
    $"supports pipelining = {servicePoint.SupportsPipelining}, " +
    $"receive buffer size = {servicePoint.ReceiveBufferSize}, " +
    $"idle since = {servicePoint.IdleSince}, " +
    $"max idle time = {servicePoint.MaxIdleTime}, ");

However the only recommended guidance is Use HttpClient instead without any details on how. Is there any known way to retrieve these properties via the HttpClient?

I found this stack overflow post that uses socketsHttpHandler instead to modify the connection lifetime but this isn't really what a want. I'm looking more to try and get these values as a 'read' operation.

I tried to find a .Net6 alternative to getting these values but couldn't.

0

There are 0 best solutions below