grpc-dotnet icon indicating copy to clipboard operation
grpc-dotnet copied to clipboard

gRPC C# .NET Framework issue WinHttpException: Error 12175 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR

Open p1x31 opened this issue 3 months ago • 1 comments

Hi! I'm hitting the same error as #1733 but with windows 11 .net framework client to .net framework server works fine .net 8 client to python server works fine

I'm getting this error with .net framework client and python server

Grpc.Core.RpcException
  HResult=0x80131500
  Message=Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. WinHttpException: Error 12175 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A security error occurred'.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request.")
  Source=mscorlib
  StackTrace:
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Grpc.Net.Client.Internal.GrpcCall`2.<GetResponseHeadersCoreAsync>d__72.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Program.<<Main>$>d__0.MoveNext() in C:\Users\*\GrpcClientTest\GrpcClientTest\Program.cs:line 53

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
HttpRequestException: An error occurred while sending the request.

Inner Exception 2:
WinHttpException: Error 12175 calling WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, 'A security error occurred.

What version of gRPC and what language are you using?

Grpc.Net.Client 2.62.0 C# .NET Framework 4.8.1

What operating system (Linux, Windows,...) and version?

Windows 11 Pro 23H2

What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info)

Visual Studio 2022 project; C# .NET Framework 4.8.1

What did you do?

If possible, provide a recipe for reproducing the error. Try being specific and include code snippets if helpful.

following WinHttpHandler official example. c# greeter client example, python greeter server example

What did you expect to see?

a returned string value from my gRPC method call

What did you see instead?

HttpRequestException

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

See TROUBLESHOOTING.md for how to diagnose problems better.

Anything else we should know about your project / environment?

Client

using var channel = GrpcChannel.ForAddress("https://localhost:7215", new GrpcChannelOptions
{
    HttpHandler = new WinHttpHandler()
});

var client = new Greeter.GreeterClient(channel);
Console.Write("name: ");
var name = Console.ReadLine();
var reply = await client.SayHelloAsync(new HelloRequest { Name = name });
Console.WriteLine($"server: {reply.Message}");
Console.ReadKey();

Server:

"""The Python AsyncIO implementation of the GRPC greet.Greeter server."""

import asyncio
import logging

import grpc
import greet_pb2
import greet_pb2_grpc


class Greeter(greet_pb2_grpc.GreeterServicer):
    async def SayHello(
        self,
        request: greet_pb2.HelloRequest,
        context: grpc.aio.ServicerContext,
    ) -> greet_pb2.HelloReply:
        return greet_pb2.HelloReply(message="Hello, %s!" % request.name)


async def serve() -> None:
    server = grpc.aio.server()
    greet_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
    listen_addr = "[::]:7215"
    server.add_secure_port(listen_addr)
    logging.info("Starting server on %s", listen_addr)
    await server.start()
    await server.wait_for_termination()


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(serve())
proto:
syntax = "proto3";

option csharp_namespace = "GrpcClientTest";

package greet;

// The greeting service definition.
service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings.
message HelloReply {
  string message = 1;
}

I have tried:



/*AppContext.SetSwitch(
 "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
*/

/*var httpHandler = new HttpClientHandler
{
    ServerCertificateCustomValidationCallback =
            HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
*/

p1x31 avatar May 17 '24 14:05 p1x31

Hi, this looks like a problem with the underlying WinHttpHandler component. Could you copy the issue here to dotnet/runtime repository? I’ll make sure the right people take a look at it.

JamesNK avatar May 18 '24 05:05 JamesNK