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 Ingress Control : All (Allow direct access to your service from the internet) Enabled Use HTTP/2 end-to-end Authentication : Allow unauthenticated invocations
The java client is connected like this
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
What am I mising here ? Any suggestions.
Any help is highly appreciated.
Thanks in advance.
Regards
Srinivasan
I found the solution. Hi,
The issue is that the client should listen to port 443 with SSL
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();