Not able to connect to Dialogflow RPC API with an agent hosted in us-central region
Problem
I have an agent created in the us-central1 region. Currently, it is not clear how to point this client to specific region using RPC API. When setting location id parameter to us-central1, exception is always thrown (see more details below). Setting endpoint to us-central1-dialogflow.googleapis.com:433 doesn't work either.
Environment details
- API: Dialogflox CX "detectIntent" over gRPC protocol
- OS type and version: macOS Sonoma
- Java version: 17
- Version(s): 0.55.0
Steps to reproduce
- Create an agent in the
us-central1location - Construct session path by specifying correct project-id, location-id (
us-central1), agent-id and session-id - Construct basic
QueryInputandDetectIntentRequestobjects - Create new session client with default settings using
SessionsClient.create() - Issue "detect intent" request using
sessionsClient.detectIntent - Following exception is thrown:
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Please refer to https://cloud.google.com/dialogflow/cx/docs/concept/region#avail and https://cloud.google.com/dialogflow/es/docs/how/region#regions to find the correct endpoint to access resources located in 'us-central1'.
Code example
String projectId = "hidden";
String locationId = "us-central1";
String agentId = "hidden";
String sessionId = "hidden";
String languageCode = "en";
String sessionPath =
SessionName.of(projectId, locationId, agentId, sessionId).toString();
QueryInput queryInput =
QueryInput.newBuilder()
.setText(TextInput.newBuilder().setText("hello").build())
.setLanguageCode(languageCode)
.build();
DetectIntentRequest detectIntentRequest =
DetectIntentRequest.newBuilder()
.setSession(sessionPath)
.setQueryInput(queryInput)
.build();
SessionsClient sessionsClient = SessionsClient.create();
DetectIntentResponse response = sessionsClient.detectIntent(detectIntentRequest);
System.out.println(response);
Stack trace
Exception in thread "main" com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Please refer to https://cloud.google.com/dialogflow/cx/docs/concept/region#avail and https://cloud.google.com/dialogflow/es/docs/how/region#regions to find the correct endpoint to access resources located in 'us-central1'.
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:92)
at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:41)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:86)
at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:66)
at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)
at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:84)
at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1130)
at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1298)
at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1059)
at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:809)
at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:568)
at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:538)
at io.grpc.PartialForwardingClientCallListener.onClose(PartialForwardingClientCallListener.java:39)
at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:23)
at io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(ForwardingClientCallListener.java:40)
at com.google.api.gax.grpc.ChannelPool$ReleasingClientCall$1.onClose(ChannelPool.java:570)
at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:489)
at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:453)
at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:486)
at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:574)
at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:72)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:742)
at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:723)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Suppressed: com.google.api.gax.rpc.AsyncTaskException: Asynchronous task failed
at com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:57)
at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
at com.google.cloud.dialogflow.cx.v3.SessionsClient.detectIntent(SessionsClient.java:326)
at org.example.Main.main(Main.java:39)
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Please refer to https://cloud.google.com/dialogflow/cx/docs/concept/region#avail and https://cloud.google.com/dialogflow/es/docs/how/region#regions to find the correct endpoint to access resources located in 'us-central1'.
at io.grpc.Status.asRuntimeException(Status.java:533)
... 17 more
Additional information
When setting location id to global, things start to work. But then my agent cannot be found, because it wasn't created in the global location obviously.
NOTE: Everything works fine when switching to the InstantiatingHttpJsonChannelProvider transport. But it would be great if we could use RPC for better efficiency.
Thanks for reporting this, I'm taking a look at this.
Setting endpoint to us-central1-dialogflow.googleapis.com:433 doesn't work either.
Could you provide a code sample/ snippet that shows how you are setting this endpoint value?
Everything works fine when switching to the InstantiatingHttpJsonChannelProvider transport.
Similarly, could you provide a code sample/ snippet that shows how you're switching to REST?
The endpoint computed when using Dialogflow would be dialogflow.googleapis.com:443 and from the docs, it seems like you would need us-central1-dialogflow.googleapis.com:433. I'm not sure why one transport works and the other doesn't.
Closing due to lack of response from reporter. Please feel free to reopen if this is still an issue for you!