Asp.net core 3.0 Grpc.AspNetCore.Server.ClientFactory Error
See original GitHub issueGrpc.Core.RpcException: Status(StatusCode=Internal, Detail="Error starting gRPC call: An error occurred while sending the request.")
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)
at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
at GrpcService2.Chat.ChatClient.SendChat(ChatRequest request, CallOptions options) in C:\Users\Aries\Desktop\ConsoleApp3\ConsoleApp3\obj\Debug\netcoreapp3.0\ChatGrpc.cs:line 92
at GrpcService2.Chat.ChatClient.SendChat(ChatRequest request, Metadata headers, Nullable`1 deadline, CancellationToken cancellationToken) in C:\Users\Aries\Desktop\ConsoleApp3\ConsoleApp3\obj\Debug\netcoreapp3.0\ChatGrpc.cs:line 88
at WebApplication1.Controllers.TestController.GetName() in C:\Users\Aries\Desktop\ConsoleApp3\WebApplication1\Controllers\TestController.cs:line 25
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
HEADERS
Cache-Control: no-cache Connection: keep-alive Content-Type: application/json Accept: / Accept-Encoding: gzip, deflate Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNrTmFtZSI6IuWPr-i-vum4rSIsImVtYWlsIjoiYWRtaW5AMTYzLmNvbSIsInVpZCI6IjB4MTAyNCIsImFwcENvZGUiOiIyMTQiLCJsb2dpblRpbWUiOiIyMDE5LTEwLTIyIDE2OjU1IiwiZXhwIjoxNTcxNzM4MTM2LCJpc3MiOiJodHRwOi8vMTI3LjAuMC4xIiwiYXVkIjoiemh1cXVlIn0.-W__S8RuM2bvj8t6ZaqwEZQ0nhjX0pc0vE_dXPyosAY Host: localhost:5000 User-Agent: PostmanRuntime/7.19.0 Content-Length: 249 Postman-Token: 605b5837-28b9-42e1-910c-a93a022f7a2a
Code:
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddGrpcClient<Chat.ChatClient>(o =>
{
o.Address = new Uri("http://192.168.1.109:5001");
});
}
public class TestController : ControllerBase
{
private readonly Chat.ChatClient _c;
public TestController(Chat.ChatClient client)
{
_c = client;
}
[HttpGet]
public ActionResult GetName()
{
var a = _c.SendChat(new ChatRequest { Name = "test request....." });
return Ok(a);
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Troubleshoot gRPC on .NET
The ASP.NET Core gRPC template and samples use TLS by default. You'll see the following error message when you attempt to start the...
Read more >Grpc client factory client doesn't wait for service to start
I am using Grpc.Net version : Grpc.AspNetCore 2.27.0. Dot net core version : Asp.Net Core 3.1. Project Sdk for Grpc service ="Microsoft.NET.
Read more >gRPC with ASP.NET Core 3.0
Abstract: gRPC is supported in the latest ASP.NET Core 3.0 release. This tutorial will cover a brief introduction to gRPC, how gRPC services ......
Read more >Implementing Microservices with gRPC and .NET Core 3.1
When starting your gRPC service, you may experience an error like the following: Microsoft.AspNetCore.Server.Kestrel[0] Unable to start Kestrel. System.IO.
Read more >How to build gRPC applications in ASP.NET Core
Learn how to use gRPC, a language-agnostic, high-performance RPC framework, to build lightweight, high-performance services in ASP.NET Core ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve found a workaround for now.
Setting this flag inside the client seems to make it work.
Not the OP, but I’m able to reproduce. It’s working fine using https but when I try over http, I get the same error.
There is nothing else in the debug logs. I’m able to access the RPC server without any issues using BloomRPC, so I suspect Grpc.Net.Client is at fault.
I’ve looked at the wireshark capture of a failed call using Grpc.Net.Client and here are the results.
It’s not really my area of expertise, but it looks like the client never initiate communication using HTTP2 and GRPC after the initial TCP handshake. The client just send the whole message over TCP and is rejected by the server.