Ocelot
Ocelot copied to clipboard
Do you have plan to support gRPC?
Hello,
I dont know that do you have any plan to support gRPC besides http?
Thanks,
@tungphuong I don't think gRPC is compatible with the idea of an API gateway like Ocelot. Ocelot has no schema whereas gRPC enforces a schema between upstream and downstream services. Also gRPC can use http as a transport so its not really besides :o
@tungphuong support grpc https://github.com/BuiltCloud/Ocelot.GrpcHttpGateway
@geffzhang that is awesome :)
@tungphuong I would suggest looking at that! I will keep this issue open and reference that project in the Ocelot docs for anyone else looking to use grpc.
This is an article about grpc gateway https://www.cnblogs.com/kingreatwill/p/9722963.html
Many thanks
@TomPallister - Hey Tom, any plan to support gRPC in Ocelot? - I'm thinking it'd be a great feature to be able to use Ocelot as a gateway (in addition to pure gRPC re-directions). Gateway meaning that external communication from Ocelot to client apps could be using HTTP, but from Ocelot to the internal microservices it'd be using gRPC.
Asking about Ocelot's implementation because the mentioned gateway above hasn't been updated in the last 8 months..
Thoughts?
@CESARDELATORRE I agreed with you. Because of .NET Core 3.0 comes a long with gRPC out of the box so that we need to have some way to forward the gRPC Request into the internal microservices. Just like envoy-filter with grpc transcode. Let me know how do you think? @TomPallister
@TomPallister @CESARDELATORRE @geffzhang Because I have got the same issue that was reported by @tungphuong in my company project so that I have added the filter which can do a transcoder for JSON to gRPC, the code can be found at https://github.com/thangchung/GrpcJsonTranscoder. It will help to add the aggregation layer that config the endpoint of all down stream gRPC services

@thangchung I have same issue so i have followed your approach and implemented exactly but getting error as below
Status(StatusCode=Internal, Detail="Error starting gRPC call: The SSL connection could not be established
I have tried to fix it but it seems the certificate is not trusted can you please help me to solve the issue.
Here goes the service code:
public class ArticlesService : Greeter.GreeterBase
{
private readonly ILogger<articlesService> _logger;
public articlesService(ILogger<articlesService> logger)
{
_logger = logger;
}
public override Task<HelloReply> AddArticle(HelloRequest request, ServerCallContext context)
{
return Task.FromResult(new HelloReply
{
Message = "Hello"
});
}
}
Here goes the proto code:
syntax = "proto3";
option csharp_namespace = "Author.Core.GrpcShare";
package greet;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc addArticle (HelloRequest) returns (HelloReply);
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings.
message HelloReply {
string message = 1;
}
Can you please tell me did you face any issue similar?
@saitejaprattipati maybe this is the issue about certificates validation - as with WebSockets?
Thang Chung (@thangchung) wrote on Aug 10, 2019:
@TomPallister @CESARDELATORRE @geffzhang Because I have got the same issue that was reported by @tungphuong in my company project so that I have added the filter which can do a transcoder for JSON to gRPC, the code can be found at https://github.com/thangchung/GrpcJsonTranscoder. It will help to add the aggregation layer that config the endpoint of all down stream gRPC services
This only will work for scenario where gRPC request-reply pattern of messaging is used. gRPC Json transcoding will not be available for gRPC Streaming scenario like file upload and download. How do we handle those kind of patterns if we do not have the load balancing
Wow! Soo exciting gRPC feature we're discussing here!
@VenkateshSrini Venkatesh, Thanks for your pinging the community!
I understand your concerns regarding third-party solutions, as you've expressed in previous message. Could you share more details please? Any practical examples with gRPC streaming scenario? I believe the main request-reply scenario is most distributed one. Could you confirm please that gRPC streaming scenario is not supported by Grpc-Json Transcoder project? Can we find some workaround here? How?
Do you have some experience with gRPC for .NET at all? Have you used C# / .NET | gRPC NuGet packages in your projects?
@thangchung Hi Thang Chung!
Thang Chung wrote on Aug 10, 2019:
Great solution you've built based on Ocelot, anyway! Good job! 🎉
I see that your GrpcJsonTranscoder project is based on:
- .NET Core 3.1 (GrpcJsonTranscoder.csproj | Line 4)
- Grpc.Core 2.27.0 package (GrpcJsonTranscoder.csproj | Line 21)
- Ocelot 14.0.11 package (GrpcJsonTranscoder.csproj | Line 23)
Would you like to upgrade the project to .NET 7, Ocelot 19.x and last release of Grpc.Core v.2.46.6 ? What about a migration of the project with usage of gRPC for .NET lib instead of Grpc.Core?
Please note if you have real working gRPC-Ocelot solution and/or great example then we could incorporate this solution to samples projects of Ocelot repository.
@thangchung Hi Thang Chung!
Thang Chung wrote on Aug 10, 2019:
Great solution you've built based on Ocelot, anyway! Good job! 🎉
I see that your GrpcJsonTranscoder project is based on:
- .NET Core 3.1 (GrpcJsonTranscoder.csproj | Line 4)
- Grpc.Core 2.27.0 package (GrpcJsonTranscoder.csproj | Line 21)
- Ocelot 14.0.11 package (GrpcJsonTranscoder.csproj | Line 23)
Would you like to upgrade the project to .NET 7, Ocelot 19.x and last release of Grpc.Core v.2.46.6 ? What about a migration of the project with usage of gRPC for .NET lib instead of Grpc.Core?
Please note if you have real working gRPC-Ocelot solution and/or great example then we could incorporate this solution to samples projects of Ocelot repository.
GrPC encoding is already available in .NET 7 out of the box. Please use that
Wow! Soo exciting gRPC feature we're discussing here!
@VenkateshSrini Venkatesh, Thanks for your pinging the community!
I understand your concerns regarding third-party solutions, as you've expressed in previous message. Could you share more details please? Any practical examples with gRPC streaming scenario? I believe the main request-reply scenario is most distributed one. Could you confirm please that gRPC streaming scenario is not supported by Grpc-Json Transcoder project? Can we find some workaround here? How?
Do you have some experience with gRPC for .NET at all? Have you used C# / .NET | gRPC NuGet packages in your projects?
@raman-m , I have produced a gRPC service that will centralize file management using file mount. It is based on Kubernetes. In this case like S3 file can be stored on a file storage like EFS or Azure file storage that can be mounted as volume mount. It is done to reduce the cost in case of public cloud with low cost file mounts. In this case both the case of Kubernetes way of load balancing is failing. The first approach
- gRPC json transcoding:- This approach is not possible because gRPC transcoding is not possible for gRPC streaming
- Headless service: It is not possible to expose an headless service on a load balancer and expose externally. Now the options available are
- Envoy proxy based load balancing. I feel it is complex
- Nginx base loadbalancing: It did not work in docker desktop for me. I was asked to try some samples with Go and since I have zero knowledge of Go I'm stuck here
I'm looking for some solution like Ocelot that can be exposed over Kubernetes Service and when I send a gRPC request to Ocelot endpoint it can load balance between the instances in the clutser. I understand this has to be tightly couple proto based end point that will be highly available. It should just identify a free service in endpoint of target service and just do a portforwading of the request. Once operation is completed re-assign these endpoints as needed. while one of the gRPC pod instance is busy working with a request when next request comes it should use the other pod available
Check the gRPC client-side load balancing
doing that now. But I feel it is a overload on client. Also, we may need Ocelot to support the same for streaming scenario
I'm not sure I understand your concerns. When Ocelot is used with its own load balancer, grpc client load balancer is an obvious choice. Otherwise, the user should be aware of grpc long-living connections and can use 3rd party solution (we are using LinkerD in k8s, for example). Regarding streaming scenario: every stream will be load balanced. If your conserns about load balancing within a single stream, than this doesn't make sense in general scenario and it's not something grpc supports. Once the stream is started it will work against the same server until the stream is finished.
@VenkateshSrini commented on June 10, 2023:
This only will work for scenario where gRPC request-reply pattern of messaging is used. gRPC Json transcoding will not be available for gRPC Streaming scenario like file upload and download. How do we handle those kind of patterns if we do not have the load balancing
Oh. You probably talked about this. Starting .NET 7 there is a transcoding support from Microsoft which also supports server streaming.
@gao-artur commented on Jun 30, 2023:
Oh. You probably talked about this. Starting .NET 7 there is a transcoding support from Microsoft which also supports server streaming.
Transcoding does not support server side streaming. Only Request reply that is issue why we cannot use Ocelot out of the box
I'm not sure I understand your concerns. When Ocelot is used with its own load balancer, grpc client load balancer is an obvious choice. Otherwise, the user should be aware of grpc long-living connections and can use 3rd party solution (we are using LinkerD in k8s, for example). Regarding streaming scenario: every stream will be load balanced. If your conserns about load balancing within a single stream, than this doesn't make sense in general scenario and it's not something grpc supports. Once the stream is started it will work against the same server until the stream is finished.
I think I will elaborate a little bit but that is going to be a long post. I'm looking at a scenario where without a http middle layer Ocelot should do the load balancing. Ocelot can itself acts as a client and then do a client load balancing that is one options. Ocelot should also be sensitive as to whether it is going to load balance a streaming request or Request Reply messaging protocol. Doing later is easy former is difficuilt. For that we can even say that we have to follow some pattern in writing gRPC services, Like allowing for Server side reflection so that the Ocelot can understand the proto contract defined by the gRPC server. We could also say that one service can have endpoints that either follow Request Reply or Streaming and not combine both in one service
@gao-artur and @VenkateshSrini Why are you discussing here a theory with such long list of messages? What is outcome of your debates?
I expect concrete user scenario(s) and real PR(s) to this repo. Please, if you have a real solution, you are welcome to create PR.
It seems I will close this issue soon because I see zero real results of such long discussions. Or the discussion will be blocked...
@gao-artur wrote on June 29, 2023
Check the gRPC client-side load balancing
Thanks for the link! I believe we must use this MS Learn doc to integrate gRPC into Ocelot: Call gRPC services with the .NET client
:warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning:
I believe Ocelot team and community should use & go with these official MS Learn docs:
- Overview for gRPC on .NET | Microsoft Learn, the root of gRPC docs
- Call gRPC services with the .NET client | Microsoft Learn, for gRPC client integration into Ocelot core (substitution of
HttpClient) - gRPC on .NET supported platforms | Microsoft Learn, some important info regarding gRPC technology in .NET versions, and gRPC hosting requirements
Ocelot team and community should borrow ideas & get some real coding recipes from these solutions and products:
- kingreatwill/Ocelot.GrpcHttpGateway: Ocelot.GrpcHttpGateway, first solution liked by Tom and community, now it is outdated, but we can still get some ideas there and probably some coding recipes.
- grpc-ecosystem/grpc-gateway: gRPC to JSON proxy generator following the gRPC HTTP spec, written in Go language, we could do some researches inside of this repo, the docs: gRPC-Gateway | gRPC-Gateway Documentation Website
:warning: The Ocelot community should use these links above :point_up: for future gRPC implementations in Ocelot core! Other custom solutions will be ignored but consideration is possible. :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning:
@tungphuong Hi Phuong Le! Are you interested in contribution and/or discussion?
You are issue reporter, and we must decide what to do with your issue!.. A soonest reply will be much appreciated!