[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to connect to Dialogflow RPC API with an agent hosted in us-central region #10941

Open
rmkol opened this issue Jun 6, 2024 · 1 comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@rmkol
Copy link
rmkol commented Jun 6, 2024

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

  1. API: Dialogflox CX "detectIntent" over gRPC protocol
  2. OS type and version: macOS Sonoma
  3. Java version: 17
  4. Version(s): 0.55.0

Steps to reproduce

  1. Create an agent in the us-central1 location
  2. Construct session path by specifying correct project-id, location-id (us-central1), agent-id and session-id
  3. Construct basic QueryInput and DetectIntentRequest objects
  4. Create new session client with default settings using SessionsClient.create()
  5. Issue "detect intent" request using sessionsClient.detectIntent
  6. 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.

@blakeli0 blakeli0 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jun 7, 2024
@lqiu96
Copy link
Contributor
lqiu96 commented Jun 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants