0

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.

  • From [HttpClient example](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-7.0#examples) we can know how to use HttpClient, and get responseBody by `string responseBody = await response.Content.ReadAsStringAsync();` . Could you share your code about these values in request.RequestUri ? – Qing Guo Jun 28 '23 at 07:34

0 Answers0