'Can not reach .Net gRPC server on Cloud Run #1653
I was trying to have a .Net Kestrel gRPC server deployed on Cloud Run. But cannot work properly.
My local environment is MacOS Big Sur Version 11.6.4.
To reproduce:
Create a new gRPC project by selecting
gRPC Servicetemplate on Visual Studio for mac 2022 PreviewChange
Program.csas below:
using GrpcGreeter.Services;
var builder = WebApplication.CreateBuilder(args);
// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
// Add services to the container.
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);
add
Dockerfilefrom [this](https://github.com/GoogleCloudPlatform/dotnet-docs-s amples/blob/main/run/helloworld/Dockerfile).Build docker image.
docker build -t gcr.io/my-project/grpc-greeter .Docker run locally
docker run --rm -p 12345:8080 gcr.io/my-project/grpc-greeterCheck by using
grpcurl. (Error message was shown but works fine becausegrpcurlhas reached my application)
$ grpcurl -plaintext 0.0.0.0:12345 list
Failed to list services: server does not support the reflection API
- Push docker image on GCR:
docker push gcr.io/my-project/grpc-greeter - Deploy to Cloud Run by using this command:
gcloud run deploy grpc-greeter --image gcr.io/my-project/grpc-greeter --port 5000 --use-http2 --region us-central1
- Run
grpcurlagain then you will see following error message. This request could not reach this application so that Cloud Run console did not show any logs.
$ grpcurl -plaintext my-project.a.run.app:443 list
Failed to dial target host "my-project.a.run.app:443": context deadline exceeded
Thank you for reading and please any help.
----- Added Mar. 7th --------------
I faced the same log message that troubleshoots said: https://cloud.google.com/run/docs/troubleshooting#sandbox
Log explore shows this message:
{
"textPayload": "Container Sandbox: Unsupported syscall setsockopt(0x7a,0x1,0xd,0x3dfb18bfeef8,0x8,0x3dfb0800ac78). It is very likely that you can safely ignore this message and that this is not the cause of any error you might be troubleshooting. Please, refer to https://gvisor.dev/docs/user_guide/compatibility/linux/amd64/setsockopt for more information.",
"insertId": "6224c2a80009b0975ebc347b",
"resource": {
"type": "cloud_run_revision",
"labels": {
"revision_name": "grpc-greeter-00005-ziq",
"location": "us-central1",
"service_name": "grpc-greeter",
"project_id": "my-project",
"configuration_name": "grpc-greeter"
}
},
"timestamp": "2022-03-06T14:18:16.634974567Z",
"severity": "DEBUG",
"labels": {
"instanceId": "00bf4bf02d3ed790c520d7b323e25ad7bbc2a7a5044f2372a67f11aa5ec3aad8379c3ed7976eda29dba06f978dc44b6a9635786f2c6a33dae4991695"
},
"logName": "projects/my-project/logs/run.googleapis.com%2Fvarlog%2Fsystem",
"receiveTimestamp": "2022-03-06T14:18:16.639213876Z"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
