title: Static HttpClient still creating TIME_WAIT tcp ports
body: <p>I am experiencing some interesting behavior with the HttpClient from the .NET Framework (4.5.1+, 4.6.1 and 4.7.2). I have proposed some changes in a project at work to not dispose of the HttpClient on each use because of the known issue with high TCP port usage, see <a href="https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/" rel="noreferrer">https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/</a>. </p>
  
  <p>I have investigated the changes to check that things were working as expected and found that we are still experiencing the same TIME_WAIT ports as before. </p>
  
  <p>To confirm that my proposed changes were correct I have added some extra tracing to the application that confirm that I am using the same instance of the HttpClient through out the application.  I have since used simple test application (taken from the aspnetmonsters site linked above.</p>
  
  <pre><code>using System;
  using System.Net.Http;
  
  namespace ConsoleApplication
  {
      public class Program
      {
          private static HttpClientHandler { UseDefaultCredentials = true };
          private static HttpClient Client = new HttpClient(handler);
          public static async Task Main(string[] args) 
          {
              Console.WriteLine("Starting connections");
              for(int i = 0; i&lt;10; i++)
              {
                  var result = await Client.GetAsync("http://localhost:51000");
                  Console.WriteLine(result.StatusCode);
              }
              Console.WriteLine("Connections done");
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>The issue only occurs when connecting to a site that is hosted in IIS using Windows Authentication.  I can reproduce the issue easily by setting the Authentication to Anonymous (problem goes away) and back to Windows Authentication (problem reoccurs).</p>
  
  <p>The issue with Windows Authentication does not seem to be limited to the scope of the provider.  It has the same issue if you us Negotiate or NTLM.  Also the issue occurs if the machine is just a workstation or part of a domain.</p>
  
  <p>Out of interest I created a dotnet core 2.1.0 console app and the issue is not present at all and works as expected.</p>
  
  <p>TLDR: Does any one have any idea on how to fix this, or is it likely to be a bug?</p>