question

ChristianHavel-3716 avatar image
0 Votes"
ChristianHavel-3716 asked ·

Invoke gRPC Service ignoring system proxy

Hi, I have implemented a simple gRPC service using .NET Core 3.1 that is running as a ConsoleApp.
I wrote a simple .NET Core 3.1 gRPC client, that is running as a Console app, too.
If I disable in the system configuration the option to detect the proxy my sample works fine.
If it is activated I get a error message and in WireShark I find the information, that the proxy blocks the call

How can I force the client not to use the proxy?
This is my client code:

var channel = new Channel($"127.0.0.1:2231", ChannelCredentials.Insecure);
_serviceClient = new MyService.MyServiceClient(channel);
var request = new HelloRequest {Name = "Franz"};
var reply = _serviceClient.SayHello(request);

And this is the relevant code from the gRPC service:

var credentials = ServerCredentials.Insecure;
var hostName = "127.0.0.1";
_port = new ServerPort(hostName, 2231, credentials);
_rpcServer = new Server { Services = {MyService.BindService(new MyServiceImpl())}, Ports = { _port }};
_rpcServer.Start();

How do I configure on client side to use or not to use the proxy? Or how can I explicit configure the proxy including the credentials on the client?
Thanks,
Christian

not-supported
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ChristianHavel-3716 avatar image
0 Votes"
ChristianHavel-3716 answered ·

Hi,

I found the solution:

 AppContext.SetSwitch(                    "System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
    
 string Ip = "My.IP.That.Works"; 
 var channel = GrpcChannel.ForAddress($"http://{Ip}:{Port}");
 MyService.MyServiceClient client = new MyService.MyServiceClient(channel);
    
 var request = new HelloRequest {Name = "MyName"};
 var reply = client.SayHello(request);

Christian

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.