0

I'm currently facing an issue with grpc-web, and a loadbalancer. Trying to call our grpc webservices from our gateway API, results in the following error:

Status(StatusCode="Unknown", Detail="Bad gRPC response. HTTP status code: 411")

It appears that the either of the following headers are required, content-length or Transfer-Encoding.

I have a method for setting metadata in my client.

private async Task<Metadata> SetMetadata()
    {
        //More stuff here
        
        headers.Add("Transfer-Encoding", "chunked");

        return headers;
    }

Here is how i create my client:

private async Task<Services.Protobuf.ServiceClient> CreateClient()
    {

        var httpMessageHandler = new HttpClientHandler();

        _grpcChannel ??= GrpcChannel.ForAddress(
            await _serviceAddressProvider.GetServiceAddress<ServiceClient>() ??
            throw new InvalidOperationException(),
            new GrpcChannelOptions()
            {
                HttpHandler = new GrpcWebHandler(httpMessageHandler)
            });
        return new(_grpcChannel);
    }

And here is how i use the two

 var serviceClient = await CreateClient();
 var request = new Request
 {
     //Request stuff
 };
 var getListReply = await serviceClient.GetListReplyAsync(request, await SetMetadata());

Now. The issue is that I cannot set either Transfer-Encoding or Content-Lenght headers. They simply get stripped somewhere. If fiddler is running they get added (by fiddler i assume), and the request actually works. But if fiddler is not running, the headers are not there, and i get the above error. (I honestly don't understand the part with fiddler, i'm only reporting what i'm seeing).

Does anyone have any idea why this happens? and if it's even possible to add the headers i'm trying to add with grpc-web?

Christian A
  • 483
  • 1
  • 10
  • 23

1 Answers1

0

I don't know much about grpc-web but grpc-gateway does strip HTTP headers if they don't have a grpcmetadata prefix when it forwards the HTTP request to the grpc server

You can take a look at this issue thread https://github.com/grpc-ecosystem/grpc-gateway/issues/1244

Palash Nigam
  • 1,653
  • 3
  • 14
  • 26