- 
                Notifications
    You must be signed in to change notification settings 
- Fork 815
Description
What version of gRPC and what language are you using?
GRPC 2.32.0 and Grpc.Net.Client 2.31.0 NuGet package with C#.
What operating system (Linux, Windows,...) and version?
Windows 10 20H2.
What runtime / compiler are you using (e.g. python version or version of gcc)
.Net Core 3.1.
What did you do?
On the gRPC server, I return response header containing server info once a request starts. On the client side, I block until I receive this information before sending the request body. This scenario works properly without issues when I use GrpcChannel.ForAddress for creating the channel. Once I switch to creating the Grpc.Core.Channel on my own, the client never receives the response headers sent from the server. Changing how the channel is created is the only code change needed to reproduce the issue and it happens consistently.
Channel creation that works:
var channel = GrpcChannel.ForAddress("http://localhost:5000");
Channel creation code that doesn't work:
 var channel = new Channel(uri.DnsSafeHost, uri.Port, ChannelCredentials.Insecure);
Server code snippt:
 public override async Task<FResult> DoWork(IAsyncStreamReader<FRequest> requestStream, ServerCallContext context)
        {
                    var headers = new Metadata() { new Metadata.Entry("serverinfo", this.serverInfo) };
            await context.WriteResponseHeadersAsync(headers).ConfigureAwait(false);
            ...
         }
Client code snippet:
         protected override Func<Task> OnNextAsync(Segment payload)
         {         
         ...
         
         var call = client.DoWork(this.metadata, cancellationToken: this.grpcCancellationTokenSource.Token);
         var headers = await call.ResponseHeadersAsync.ConfigureAwait(false);
         
         ...
         }
The following line that reads the response headers on the client side never returns in the faulty case, although by debugging I can verify that the server executed await context.WriteResponseHeadersAsync.
var headers = await grpc.ResponseHeadersAsync.ConfigureAwait(false);
What did you expect to see?
Expected the response headers to be received by the client.
What did you see instead?
The client awaits but never receives the response header.