I am trying to see CurrentConnections property in ServicePoint object, but it's returning zero for me always even if I use any public URI; I am using .NET Core. Could someone please tell me if I am missing something?
Here is snippet of my test case:
IHttpClientFactory clientFactory = serviceProvider.GetService<IHttpClientFactory>();
HttpClient client = clientFactory.CreateClient();
var taskList = new List<Task<HttpResponseMessage>>();
foreach (var item in Enumerable.Range(0, 1000))
{
taskList.Add(Task.Run(async () =>
{
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "https://www.bing.com/");
ServicePoint servicePoint = ServicePointManager.FindServicePoint(httpRequestMessage.RequestUri);
if (servicePoint.CurrentConnections > 0)
{
Assert.Fail($"Found non zero connection = {servicePoint.CurrentConnections}");
}
return await client.SendAsync(httpRequestMessage);
}
));
}