question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChannelCredentials.Insecure + corporate proxy = Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.

See original GitHub issue

What version of gRPC and what language are you using?

  • Grpc.Net.Client - 2.38.0

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

  • Windows 20H2 (10.0.19042)

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

  • 5.0.400

What did you do?

Scenario a) Secure Connection

var uri = new Uri($"https://{options.Host}:{options.Port}");
rpcChannel = GrpcChannel.ForAddress(uri);
Case 1: Circumvent the corporate proxy (=direct connection to the service)

To circumvent the corporate proxy, I set it to HTTPS_PROXY=:

HTTPS_PROXY= ./Client.exe

The gPRC connection works. ✓

Case 2: Use the corporate proxy
HTTPS_PROXY=http://corporate-proxy ./Client.exe

The gPRC connection works. ✓

Scenario b) Insecure Connection

var uri = new Uri($"http://{options.Host}:{options.Port}");
var grpcChannelOptions = new GrpcChannelOptions
{
    Credentials = ChannelCredentials.Insecure
};
GrpcChannel grpcChannel = GrpcChannel.ForAddress(uri, grpcChannelOptions);
[...]
Case 3: Circumvent the corporate proxy (=direct connection to the service)
HTTP_PROXY= ./Client.exe

The gPRC connection works. ✓

Case 4: Use the corporate proxy
HTTP_PROXY=http://corporate-proxy ./Client.exe

The gPRC connection does not work. I get the following exception: System.Net.Http.HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled. The connection occus immediately, it does not even try to connect (nothing can be seen in Wireshark).

System.AggregateException: One or more errors occurred. (Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.", DebugException="System.Net.Http.HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)"))
 ---> Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.", DebugException="System.Net.Http.HttpRequestException: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at Grpc.Net.Client.Internal.GrpcCall`2.RunCall(HttpRequestMessage request, Nullable`1 timeout)")
   at Grpc.Net.Client.Internal.HttpClientCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)

What did you expect to see?

Case 4 should connect with a proxy as well.

What did you see instead?

See Case 4.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesNKcommented, Oct 6, 2021

I haven’t seen this situation before, but my guess is your HTTP_PROXY server supports HTTP/1.1 and HTTP/2.

TLS (aka HTTPS) is required to negotiate an HTTP/2 connection when a server supports multiple. Because you’re using HTTP, the connection is falling back to HTTP/1.1.

I’ll double-check this with some experts. The error message is unclear.

0reactions
JamesNKcommented, Oct 18, 2021

I don’t know. You should create an issue at dotnet/runtime to talk to the experts who work on the underlying client networking.

This isn’t an issue in gRPC or something that we can fix here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - .NET 5 GRPC client call throws exception: Requesting ...
NET 5 GRPC client call throws exception: Requesting HTTP version 2.0 with version policy RequestVersionOrHigher while HTTP/2 is not enabled.
Read more >
Troubleshoot gRPC on .NET
The following error message is returned when calling a gRPC service without a trusted certificate: Unhandled exception. System.Net.Http.
Read more >
HTTP/2 access failing on proxy when server does not ...
Cause. The Proxy policy trace will show the following information on the version requested by the client and supported by the server. server....
Read more >
How To Set Up Nginx with HTTP/2 Support on Ubuntu 18.04
The first change we will make will be to modify your domain's server block to use HTTP/2. Open the configuration file for your...
Read more >
How to use HTTP/2 with HttpClient in .NET 6.0
In this article, we will look into the different ways to configure HttpClient to use HTTP/2 standard in .NET 6.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found