Changing the dotnet sample HelloWorld to handle GRPC fails
See original GitHub issueI was trying to have a Kestrel GRPC server deployed on Google-Cloud Run as the documentation says it’s legit to do so. I started from the run/helloworld
standard HTTP/1.1 Kestrel web-app, which works fine. Mixing it with a standard Kestrel GRPC project fails. To reproduce:
- Create a new GRPC server:
dotnet new grpc TestGrpc
(tested with .net5.0 and .net6.0); - Change the
Program.cs
to match Cloud Run expectations:
using Test.Services;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddGrpc();
var port = Environment.GetEnvironmentVariable("PORT") ?? "8080";
var url = $"http://0.0.0.0:{port}";
var app = builder.Build();
// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();
app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
app.Run(url);
- Use the very same
Dockerfile
as provided in this documentation; - Build the image and push it in Artifacts Registry;
- Create a Cloud Run instance with that image: note that Kestrel requires HTTP/2 so we need to set Cloud Run to end-to-end HTTP/2 (otherwise it fails with a
protocol error
); - Run a simple client (or grpcurl) and you will get the error:
upstream connect error or disconnect/reset before headers. reset reason: remote reset
- On the other hand, on the Cloud Run instance there’s a unique log about that request with for instance (but it never reaches the actual implementation, I’ve tried logging pretty much everywhere it’s just like if there was some kind of middle-ware before reaching the user implementation that would block everything):
POST 200 1.02 KB 41 ms grpcurl/v1.8.6 grpc-go/1.44.1-dev https://***/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo
Maybe there is something obvious I am missing, but any help would be appreciated. (I also posted on stackoverflow). I am eager to contribute in any possible way, whether it be helping creating a doc on how to have a .NET GRPC server on Cloud Run, or even investigate further if need be.
Note that it used to work a few days/week ago as I had a fully operational instance running but I can’t explain why it does not succeed anymore.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Error on helloworld example · Issue #380 · grpc/grpc-web
Hi! I just try to run the hello world example to try this project but I'm facing a upstream connect error or disconnect/reset...
Read more >Tutorial: Create a gRPC client and server in ASP.NET Core
This tutorial shows how to create a gRPC Service and gRPC client on ASP ... NET gRPC client fails with the message The...
Read more >Basic changes to Hello World GRPC
My code is included, which appears not to work because it expects the pb variable to be a HelloWorld object, or something, as...
Read more >Intro to gRPC in C# - How To Get Started, - YouTube
There is a lot of buzz around gRPC right now. The biggest thing I hear is that it is confusing and people aren't...
Read more >Quick start | Go
This guide gets you started with gRPC in Go with a simple working example. ... Change to the quick start example directory:.
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 Free
Top 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
Just as un update, I’ve reported this internally and it’s being looked at. Do follow the issues in the issue tracker, but I’ll also update here as soon as I know more.
I have an update from the Cloud Run team.
The change that caused this breakage has been rolled back. The old behavior will be supported for the time being, and if/when it is deprecated, Google Cloud deprecation policies will be applied.
That said, setting KestrelServerOptions.AllowAlternateSchemes to true shouldn’t have any adverse effect on your running service, but do take care to follow the recommendations on the option documentation (KestrelServerOptions.AllowAlternateSchemes).
Thanks for your patience.