How to point a workflow client or a worker to the remote instance of Temporal server?

Hello everyone,
The WorkflowServiceStubs is always used in java examples:

// WorkflowServiceStubs is a gRPC stubs wrapper that talks to the local Docker instance of the Temporal server.
WorkflowServiceStubs service = WorkflowServiceStubs.newInstance();

Do you have an example of how to connect to a remote Temporal server?

    WorkflowServiceStubs service =
        WorkflowServiceStubs.newInstance(
            WorkflowServiceStubsOptions.newBuilder().setTarget("host:port").build());

Thanks a lot @maxim .

Hi Maxim,

In a K8 environment where both temporal and the service wanting to connect to temporal were both running in the default namespace would the "host:port" be the `temporal-frontend` or `temporal-frontend-headless` service that needs to be connect to? e.g   .setTarget("http://temporal-frontend:7233")

Either one would work with the difference is in how clients will end up being routed to specific frontend pods.

That said, the headless version of the service is more for service discovery (IPs of each pod) and the non-headless frontend provides an internally load balanced service (1 ip that is balanced across all available pods).

So the recommendation here would be to use the non-headless version unless you want clients to talk to specific frontends for some reason (not normally something you want to do).

Thanks Derek.

Hi @maxim ,

I tried the same way for Temporal server in Docker image in a different machine.
I am able to the see the emporal Ui but this code gives me connection error.

The target is passed to gRPC directly. You might need a different format in your case. Here is the list of possible formats.

Accessing docker based services from another machine requires special network configuration. I would consult with docker-compose/docker documentation.