title: Getting Cannot access a disposed object. Object name: 'SocketsHttpHandler' exception in .Net 6 Application
body: <p>In one of my Azure Function app(.Net 6 isolated process) and I am making some http requests with a client certificate. I'm registering my services in the Program.cs like this,</p>
  <pre><code>var handler = new HttpClientHandler();
  handler.ClientCertificates.Add(clientCertificate);
  
  services.AddHttpClient().Configure&lt;HttpClientFactoryOptions&gt;(
                 &quot;myClient&quot;, options =&gt;
                     options.HttpMessageHandlerBuilderActions.Add(builder =&gt;
                         builder.PrimaryHandler = handler));
  
  services.AddTransient&lt;IMyCustomClient, MyCustomClient&gt;(provider =&gt;
             new MyCustomClient(provider.GetService&lt;IHttpClientFactory&gt;(),
                 cutomParameter1, cutomParameter2));
  
  services.AddSingleton&lt;IMyCustomService, MyCustomService&gt;();
  </code></pre>
  <p>And injecting MyCustomClient in MyCustomService constructor</p>
  <pre><code>private readonly IMyCustomClient _myCustomClient;
  
  public PlatformEventManagementService(IMyCustomClient myCustomClient)
  {
      _myCustomClient = myCustomClient;
  }
  </code></pre>
  <p><code>var result = await _myCustomClient.GetResponse();</code></p>
  <p>It works fine for some time and getting the below exception after sending many requests.</p>
  <p><code>Cannot access a disposed object. Object name: 'SocketsHttpHandler'.</code></p>