Connect C# GRPC client to Go Server

Viewed 2334

I'm attempting to connect to a Go GRPC Server from a C# Client but the client channel is failing to connect to the server.

I would expect that there should be no issues in connecting to a GRPC server that is written and hosted by Go and a client written in C#.


My Go Server connection is setup thus:

lis, err := net.Listen("tcp", ":50051")
if err != nil {
    log.Fatalf("Failed to listen: %v", err)
}

s := grpc.NewServer()

pb.Register**ServiceServer(s, &server{})
reflection.Register(s)
if err := s.Serve(lis); err != nil {
    log.Fatalf("Failed to serve: %v", err)
}

This is fairly standard and I know that my Server is working as I am able to connect with a Go client using the supplied port:

conn, err := grpc.Dial("localhost:50051", grpc.WithInsecure(), grpc.WithBlock())

But when I attempt to connect using a C# Client using the Grpc.Net.Client package as thus:

var channel = GrpcChannel.ForAddress(@"http://localhost:50051", new GrpcChannelOptions
{
   Credentials = ChannelCredentials.Insecure
});

I get a Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.")' exception.

Or by using the Grpc.Core package as thus:

var channel = new Channel("localhost:50051", ChannelCredentials.Insecure);

results in a Grpc.Core.RpcException: 'Status(StatusCode=Unavailable, Detail="failed to connect to all addresses")' exception.

I've tried both methods with and without Http2UnencryptedSupport set within the C# client but I've run out of ideas on why I am unable to connect.

Any suggestions on where I am going wrong would be appreciated.

1 Answers
Related