title: Error starting gRPC call. HttpRequestException: Connection reset by peer SocketException: Connection reset by peer
body: <p>I have asp.net core 3.1 Grpc Server and asp.net core 3.1 Grpc client application. Intermittently I see the below error happening :</p>
  <pre><code>Status(StatusCode=Internal, Detail=&quot;Error starting gRPC call. HttpRequestException: Connection reset by peer SocketException: Connection reset by peer&quot;)
  </code></pre>
  <p>Here goes the Grpc client code:</p>
  <pre><code>public static async Task &lt; TResponse &gt; CallService &lt; TResponse &gt; (string urlGrpc, Func &lt; GrpcChannel, Task &lt; TResponse &gt;&gt; func) {
      AppContext.SetSwitch(&quot;System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport&quot;, true);
      AppContext.SetSwitch(&quot;System.Net.Http.SocketsHttpHandler.Http2Support&quot;, true);
  
      var channel = GrpcChannel.ForAddress(urlGrpc);
      // var channel = GrpcChannel.ForAddress(&quot;http://localhost:32769&quot;);            
      /*
   using var httpClientHandler = new HttpClientHandler
   {
       ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =&gt; { return true; }
   };
  
   */
      Log.Information(&quot;Creating grpc client base address urlGrpc ={@urlGrpc}, BaseAddress={@BaseAddress} &quot;, urlGrpc, channel.Target);
  
      try {
          return await func(channel);
      } catch(RpcException e) {
          Log.Error(&quot;Error calling via grpc: {Status} - {Message}&quot;, e.Status, e.Message);
          return
      default;
      } finally {
          AppContext.SetSwitch(&quot;System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport&quot;, false);
          AppContext.SetSwitch(&quot;System.Net.Http.SocketsHttpHandler.Http2Support&quot;, false);
      }
  }
  </code></pre>
  <p>I have been using Azure Dev Spaces for debugging in my local environment.</p>
  <p>Can anyone help me here by providing their guidance to fix this issue.</p>