I am new to GRPC and Cloud Run. I have written a very simple grpc java service. The same service works fine when I run them locally. However, when I deploy to cloud run,I am not able to call the grpc server. The grpc service is listening on port $PORT(8080) as specified in the document.
The server code is
Server server = ServerBuilder.forPort(port).addService(this).build(); server.start();
The following are the cloud run configurations for the grpc server
Ingress Control : Internal
Enabled Use HTTP/2 end-to-end
Authentication : Allow unauthenticated invocations
The java client which is also a cloud run service uses this code to connect with the grpc server
ManagedChannel channel = ManagedChannelBuilder.forAddress(grpcHost, grpcPort).usePlaintext().build(); SimpleGrpcServiceBlockingStub grpcStub = SimpleGrpcServiceGrpc.newBlockingStub(channel);
The grpcHost is xxxxx.a.run.app (without https) and the grpcPort is 8080.
The Client Cloud run service is configured with
Ingress Control : All (Allow direct access to your service from the internet)
Connect to a VPC for outbound traffic - Enabled
Send traffic directly to a VPC - uses default VPC
Traffic Routing - Route all traffic to the VPC
While running the client I get the following error
io.netty.channel.ConnectTimeoutException: connection timed out: xxx.run.app/216.239.32.53:8080
What am I mising here ? Any suggestions.
Any help is highly appreciated.
Thanks in advance.
Regards
Srinivasan
Solved! Go to Solution.
Hi,
Thank you for your response. The issue is that the client should listen to port 443.
The following code change helped me to connect with GRPC server in cloud run
SslContext sslCtxt = GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
ManagedChannel channel = NettyChannelBuilder.forAddress(utilGrpcHost, utilGrpcPort)
.sslContext(sslCtxt).build();
Regards
Hi @srinimk,
Welcome to Google Cloud Community!
You may want to check this documentation on troubleshooting Cloud Run issues, especially the following points:
Verify that you can run your container image locally. If your container image cannot run locally, you need to diagnose and fix the issue locally first.
Check if your container is listening for requests on the expected port as documented in the container runtime contract. Your container must listen for incoming requests on the port that is defined by Cloud Run and provided in the PORT
environment variable. See Configuring containers for instructions on how to specify the port.
Check if your container is listening on all network interfaces, commonly denoted as 0.0.0.0
.
Verify that your container image is compiled for 64-bit Linux as required by the container runtime contract.
Use Cloud Logging to look for application errors in stdout
or stderr
logs. You can also look for crashes captured in Error Reporting.
You may also check this documentation for currently known issues for Cloud Run as this may affect your current setup.
If the aforementioned steps didn't work or were not applicable, you may file a bug so that our engineers could take a look at this. We don't have a specific ETA for this one but you can keep track of its progress once the ticket is created.
Hope this helps.
Hi,
Thank you for your response. The issue is that the client should listen to port 443.
The following code change helped me to connect with GRPC server in cloud run
SslContext sslCtxt = GrpcSslContexts.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build();
ManagedChannel channel = NettyChannelBuilder.forAddress(utilGrpcHost, utilGrpcPort)
.sslContext(sslCtxt).build();
Regards