Calling Other Service using GRPC

could you please give us step by step process how to connect with one service with other service hosted in same kalix environment, document below doesn’t have exact details to identify other service with name.

1 Like

This is done by using the name the other service was deployed.

From the docs:

We call actionContext().getGrpcClient with the service interface of the API and the name that the service was deployed with.

In the first snippet showing Java/Scala code, you have the following:

CounterService counterService = 
  actionContext().getGrpcClient(CounterService.class, "counter"); 

Here we are creating a gRPC client that will resolve to a Counter Service identified by “counter”.

do i need to do anything for the above configuration in application.Config, getting below error while running two services in local, no error if i declare host and port in application.config, do we need akka.grpc.client, host and port name to be declare in application.config while promoting it kalix environment? please help?

Error in case i remove akka.grpc.client in local:
July 14, 2023 9:57:26 AM io.grpc.internal.ManagedChannelImpl$NameResolverListener handleErrorInSyncContext
WARNING: [Channel<5>: (//Connection)] Failed to resolve name. status=Status{code=UNKNOWN, description=No such host is known (Connection), cause=null}

Application.config in local:
akka.grpc.client {
“Connection” {
host = 127.0.0.1
port = 9002
use-tls = false
}
}

Getting below error while using above code in kalix environment.

WARNING: [Channel<5>: (//connection)] Failed to resolve name. status=Status{code=UNKNOWN, description=connection: Name or service not known, cause=null}

note: not set any value for connection in akka.grpc.client object in application.conf

Have you seen this page in our documentation?

It explains how to configure your local environment to run more than one Kalix service and let them ‘find’ each other. You should not tweak the application.conf directly because this is the file that will be used in production.

So basically, you code should still refer to the other service by name. When running in prod, Kalix will do the resolution automatically for you. When running locally, you need to pass some extra configs to the proxies and to your app in order to ‘teach’ it how to resolve the names to the right host and port.

Make sure you are using a new version of the Kalix SDK. It should be version 1.3.1 (the latest) and the Proxy version in docker-compose file must also be the latest one (1.1.15).