Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have been looking at this for a long time, looking through all the different posts on the internet to see if I could find someone with the same issue but somehow I seem to be the only have having this issue.

I have an ASP.net Core server running the basic greeter service of Grpc. Calling this server using the program "BloomRPG" work great, and has excellent response times. However when I try to do the same from my own written (very basic) client I get the following errors:

On the Client:

dbug: Grpc.Net.Client.Internal.GrpcCall[1] Starting gRPC call. Method type: 'Unary', URI: 'https://www.MYSERVER.com:50005/greet.Greeter/SayHello'. dbug: Grpc.Net.Client.Internal.GrpcCall[18] Sending message. trce: Grpc.Net.Client.Internal.GrpcCall[21] Serialized 'TestService1.HelloRequest' to 15 byte message. trce: Grpc.Net.Client.Internal.GrpcCall[19] Message sent. fail: Grpc.Net.Client.Internal.GrpcCall[6] Error starting gRPC call. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The response ended prematurely. at System.Net.Http.HttpConnection.FillAsync() at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task 1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at Grpc.Net.Client.Internal.GrpcCall 2.RunCall(HttpRequestMessage request, Nullable 1 timeout) info: Grpc.Net.Client.Internal.GrpcCall[3] Call failed with gRPC error status. Status code: 'Internal', Message: 'Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The response ended prematurely.'. dbug: Grpc.Net.Client.Internal.GrpcCall[4] Finished gRPC call. dbug: Grpc.Net.Client.Internal.GrpcCall[8] gRPC call canceled. Unhandled exception. Grpc.Core.RpcException: Status(StatusCode="Internal", Detail="Error starting gRPC call. HttpRequestException: An error occurred while sending the request. IOException: The response ended prematurely.", DebugException="System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The response ended prematurely. at System.Net.Http.HttpConnection.FillAsync() at System.Net.Http.HttpConnection.ReadNextResponseHeaderLineAsync(Boolean foldedHeadersAllowed) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task 1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at Grpc.Net.Client.Internal.GrpcCall 2.RunCall(HttpRequestMessage request, Nullable 1 timeout)") at GrpcGreeterClient.Program.Main(String[] args) in C:\Users\MYUSERNAME\source\repos\grpc\TestgrpcClient\TestgrpcClient\Program.cs:line 64 at GrpcGreeterClient.Program.(String[] args)

on the server:

fail: Microsoft.AspNetCore.Server.Kestrel[0] HTTP/2 over TLS was not negotiated on an HTTP/2-only endpoint.

Since I am succesfully calling the service with BloomRPC I suppose the issue is with my client:

Client code:

        AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
        var loggerFactory = LoggerFactory.Create(logging =>
            logging.AddConsole();
            logging.SetMinimumLevel(LogLevel.Trace);
        var httpclient = new HttpClient();
        httpclient.DefaultRequestVersion = new Version(2, 0);
        using var channel = GrpcChannel.ForAddress("https://www.MYSERVER.com:50005",
            new GrpcChannelOptions { LoggerFactory = loggerFactory, HttpClient = httpclient});
        var client = new Greeter.GreeterClient(channel);
        var reply = await client.SayHelloAsync(
                          new HelloRequest { Name = "GreeterClient" });
        Console.WriteLine("Greeting: " + reply.Message);
        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();

anyone have any idea what I could try next? I feel like I have exhausted all my options :(

You have a TLS authentication error. TJS 1.0/1.1 was discontinued in June and you must use TLS 1.2 Make sure you have the latest APIs and dlls. Older versions will not work with TLS 1.2. Also if you are using any sample code make sure you have the latest code. – jdweng Aug 14, 2020 at 19:40 Okay, I have added a httpclienthandler that forces use of TLS 1.2 in the constructor of the httpclient from above but it gives exactly the same error. Going to internet options on the pc shows that TLS 1.2 is enabled – robin sluyter Aug 14, 2020 at 20:19 No editing that comment anymore? Anyway, I also felt the need to add I use a self contained client, so that should mean no dependencies on the host right? I tried executing from a different computer and the client works, but not from the first computer. So not something with the client but with the computer then? – robin sluyter Aug 14, 2020 at 20:31 Use a sniffer like wireshark or fiddler and compare the first working request with the one not working. There is a default header that is wrong or not being set. – jdweng Aug 15, 2020 at 0:50 Experimenting with Wireshark has shown me that there is a company proxy server interfering. My guess is that this stops my client from creating a good connection. The only question I have left then is: why does BloomRPC from the same pc work? Should it not have the same interference? – robin sluyter Aug 15, 2020 at 6:35

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.