[Solved] Grpc.Core.RpcException:“Status(StatusCode=Internal, Detail=”Error starting gRPC call: An error occurred while sending the request.”)”

Environmental description

Error content

Grpc.Core.RpcException:“Status(StatusCode=Internal, Detail="Error starting gRPC call: An error occurred while sending the request.")”


Problem solving instructions 1
Problem solving instructions 2
Add the AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
client code before the client grpc request as follows

        static async Task Main(string[] args)
            // The port number(5001) must match the port of the gRPC server.
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            using var channel = GrpcChannel.ForAddress("http://localhost:5001");
            var client = new Greeter.GreeterClient(channel);
            var reply = await client.SayHelloAsync(
                              new HelloRequest { Name = "GreeterClient" });
            Console.WriteLine("Greeting: " + reply.Message);
            Console.WriteLine("Press any key to exit...");

Suggestion: go directly.NET 5

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *