title: WinHttpException: The connection with the server was terminated abnormally
body: <p>I have an ASP.Net Core Wep API Project which does the following tasks:</p>
  
  <ul>
  <li>Receive request through a controller called ProcessController.</li>
  <li>Take the incoming request and format the data into a string.</li>
  <li>Uses the PostChargeAsync method in the following HttpProcessor class to post the above formatted message on an URL and await for the responnse message to perform further processing.</li>
  </ul>
  
  <p><strong>Note</strong> that HttpClient is injected using IoC and is a singleton.</p>
  
  <pre><code>public class HttpProcessor
  {
      private readonly HttpClient _httpClient;
  
      public HttpProcessor(HttpClient httpClient)
      {
          _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));            
      }
  
      public async Task&lt;string&gt; PostChargeAsync(string payload)
      {
          using (var httpRequest = BuildHttpRequest(payload))
          {
              try
              {
                  using (var httpResponse = await _httpClient.SendAsync(httpRequest).ConfigureAwait(false))
                  {
                      httpResponse.EnsureSuccessStatusCode();
  
                      using (var httpContent = httpResponse.Content)
                      {
                          return await httpContent.ReadAsStringAsync();
                      }
                  }
              }
              catch (HttpRequestException ex)
              {
                  throw;
              }
              catch (TimeoutException ex)
              {
                  throw;
              }
              catch (System.Exception ex)
              {
                  throw;
              }
          }
      }
  
      private HttpRequestMessage BuildHttpRequest(string content)
      {
          return new HttpRequestMessage
          {
              Content = new StringContent(content, Encoding.UTF8, "application/xml"),
              Method = HttpMethod.Post,
              RequestUri = new Uri("https://test/process"),
          };
      }
  }
  </code></pre>
  
  <p>The <strong>issue</strong> is that when parallel requests (~30 - 50 requests/min) are sent on the ProcessController and the PostChargeAsync method is called I get the following exception:</p>
  
  <pre><code>System.Net.Http.HttpRequestException: An error occurred while sending the request. ---&gt; System.Net.Http.WinHttpException: The connection with the server was terminated abnormally
  </code></pre>
  
  <p>I have tried adding the following setting in Web.Config for increasing the maxconnection in connectionManagement:</p>
  
  <pre><code>  &lt;system.net&gt;
      &lt;connectionManagement&gt;
        &lt;add address="*" maxconnection="100"/&gt;
      &lt;/connectionManagement&gt;
    &lt;/system.net&gt;
  </code></pre>
  
  <p>but I still get the above mentioned exception.</p>
  
  <p>Any ideas what would have caused the above issue?</p>