question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing the dotnet sample HelloWorld to handle GRPC fails

See original GitHub issue

I 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:

  1. Create a new GRPC server: dotnet new grpc TestGrpc (tested with .net5.0 and .net6.0);
  2. 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);
  1. Use the very same Dockerfile as provided in this documentation;
  2. Build the image and push it in Artifacts Registry;
  3. 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);
  4. Run a simple client (or grpcurl) and you will get the error:
upstream connect error or disconnect/reset before headers. reset reason: remote reset
  1. 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:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
amanda-tarafacommented, Feb 23, 2022

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.

0reactions
amanda-tarafacommented, Feb 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found