I'm trying to get Microsoft's gRPC "Greeter" application to work on my business laptop, but I keep getting the following exception when invoking the gRPC call:
Grpc.Core.RpcException: 'Status(StatusCode=Internal, Detail="Error starting gRPC call: No such host is known.")'
This is the documentation from Microsoft, which I followed. The exact code I'm running comes from Microsoft's samples and can be found on their github here.
It literally boils down to starting the most basic gRPC server and then invoking the call via
using var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });
The call to SayHelloAsync is the one that throws the exception.
The exact same code on my home machine works fine.
I've already checked my /etc/hosts file for weird entries, but nothing.
I've also tried changing https://localhost:5001
to https://[::1]:5001
and https://127.0.0.1:5001
, same exception, which I find incredibly weird.
I've also already tried http via AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
and calling the http endpoint, same exception.
I figured it out. As expected it was a problem with the networking setup of my work laptop.
I had the HTTP_PROXY and HTTPS_PROXY environment variables set. These were picked up by the underlying HttpClient and tried routing the requests through the proxy. Removing the HTTP_PROXY and HTTPS_PROXY environment variables fixed the problem.
Alternatively setting the NO_PROXY environment variable to localhost,127.0.0.1,::1
also fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With