- ABP Framework version: v7.0.3
- DB provider: EF Core
- Project Template: Microservice
Need help on how to implement grpc for a microservice solution. I followed the article here: https://community.abp.io/posts/using-grpc-with-the-abp-framework-2dgaxzw3 but this was for a single-layer application project.
We have multiple host services running and each have a different port for gRPC, how can I configure to forward them in the WebGateway project?
6 Answer(s)
-
0
We have eShopOnAbp sample demonstrates it that you can check. BasketService making gRPC request to CatalogService.
-
0
Hi, I think it was not related to my case, basket service is just another service that acts as a client that requests to catalogservice. My question is related to gateway, I wanted the client to only call request into a single url or the url of webgateway proxy that routes the request to the grpc server hosts (these hosts are containerized and is inside a private network). The microservice service template project is using ocelot.
-
0
Hi,
There is still an open issue about gRPC support for Ocelot however It may not be supported at all. We have an internal issue about changing the gateway library and we will try to hasten our discussion for a solution about this subject.
Unfortunatelly we don't have a sample for the web or public-web application making a gRPC request through the gateway to a microservice. The gateway should have support for non-http protocol redirects. Maybe you can change ocelot to YARP and try it. There is a documentation about Proxying gRPC.
-
0
Hi, Okay so I changed the gateway from Ocelot to Yarp but I have problems with authentication,
Volo.Abp.Authorization.AbpAuthorizationException: Exception of type 'Volo.Abp.Authorization.AbpAuthorizationException' was thrown.
if (Self._grpcChannel == null) { var grpcOptions = Self._serviceProvider.GetRequiredService<IOptions<GrpcServiceOptions>>().Value; var userAccount = Self._serviceProvider.GetRequiredService<UserAccountSessionManager>(); var token = userAccount.AccessTokenInfo.AccessToken; var credentials = CallCredentials.FromInterceptor((context, metadata) => { if (!string.IsNullOrEmpty(token)) { metadata.Add("Authorization", $"Bearer {token}"); } return Task.CompletedTask; }); Self._grpcChannel = GrpcChannel.ForAddress(grpcOptions.GrpcServiceUri, new GrpcChannelOptions { Credentials = ChannelCredentials.Create(new SslCredentials(), credentials) }); } return Self._grpcChannel;
-
0
Hi,
This has been here week ago, we needed the grpc to be on the webgateway since we don't expose the microservices. Is there a backlog or a roadmap on abp dev team where we can possibly implement this later with abp?
-
0
Technically adding
Authorization
header withBearer
token should work as documented in https://learn.microsoft.com/en-us/aspnet/core/grpc/authn-and-authz?view=aspnetcore-7.0If you check with wireshark or similar tools, does your gRPC request to YARP contain this header? Can you pinpoint the exact problem if it is about the request to YARP or after the YARP? You may need to route the header manually perhaps https://microsoft.github.io/reverse-proxy/articles/header-routing.html
I don't have a sample for this scenario unfortunatelly. I have it on backlog and check it whenever I find time.