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.

gRPC call throws an exception: Status(StatusCode=Internal, Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.")

See original GitHub issue

I checked all “Closed” issues I could find. None of them helped.

What version of gRPC and what language are you using?

Using C# with Nuget packages: Grpc.Net.Client - 2.28.0 Grpc.Tools - 2.28.1 Google.Protobuf v3.11.4

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

Windows 10 Pro

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

Microsoft Visual Studio Community 2019 Version 16.5.3 Building .Net Core 3.1 Console app

.NET Core SDK (reflecting any global.json): Version: 3.1.201 Commit: b1768b4ae7

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.201\

Host (useful for support): Version: 3.1.3 Commit: 4a9f85e9f8

.NET Core SDKs installed: 3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

What did you do?

Used different options to create a channel. It would be too much if I showed all options I tried with different SocketsHttpHandler and HttpClient and GrpcChannelOptions and HttpClientHandler. The basic code which should work is below.

static string username = "un";
static string password = "pp";
static byte[] data = Encoding.ASCII.GetBytes(username + ":" + password);
static string encodedCredentials = System.Convert.ToBase64String(data);

private static GrpcChannel CreateAuthenticatedChannel(string address)
        {
            //using CallCredentials and below SslCredentials
            var credentials = CallCredentials.FromInterceptor((context, metadata) =>
            {
                metadata.Add("Authorization", $"Basic {encodedCredentials}");
                metadata.Add("Content-Type", "UTF8");
                //metadata.Add("ContentType", "UTF8");
                //metadata.Add("User-Agent", "grpc-dotnet/2.25.0.0");
                //metadata.Add("grpc-accept-encoding", "identity,gzip");
                //metadata.Add("Content-Type", "application/grpc");
                return Task.CompletedTask;
            });
            // SslCredentials is used here because this channel is using TLS.
            var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions
            {
                Credentials = ChannelCredentials.Create(new SslCredentials(), credentials)
            });
            return channel;
        }

Then call the service

var channel = CreateAuthenticatedChannel("https://mysite");
var client = new MyDbService.MyDbServiceClient(channel);
var result = client.usersearch(new UserSearch());

What did you expect to see?

Expect not to get an exception with Status(StatusCode=Internal, Detail=“Bad gRPC response. Response protocol downgraded to HTTP/1.1.”)

What did you see instead?

An exception

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
yshteinmcommented, Apr 25, 2020

Cannot accept that. I confirmed that server does support HTTP/2 and I am not sure what you mean by “intermediate” server. I cannot guarantee that every server on the way supports HTTP/2 which they should as they work as proxies. Unfortunately will not be able to use gRPC till it matures.

0reactions
BrutalHexcommented, Feb 13, 2021

you can not configure it to use HTTP/2, because the connection downgrades to HTTP/1.1 thus it fails since gRPC only works with Http2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grpc Client throws Grpc.Core.RpcException (Response ...
HResult=0x80131500 Message=Status(StatusCode="Internal", Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.
Read more >
Grpc Error - Issues
Exception ='Grpc.Core. ... Status(StatusCode=“Internal”, Detail=“Bad gRPC response. Response protocol downgraded to HTTP/1.1.”).
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 >
Emulator support
Grpc.Core.RpcException : Status(StatusCode="Internal", Detail="Bad gRPC response. Response protocol downgraded to HTTP/1.1.").
Read more >
Implementing Microservices with gRPC and .NET Core 3.0
Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Internal, Detail=“Bad gRPC response. Response protocol downgraded to HTTP/1.1 ...
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