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.