有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

spring boot无法通过java cloud sdk调用GCP NLP

我需要谷歌云服务与SpringBoot应用程序集成方面的技术帮助

简介:我正在尝试使用谷歌云java sdk获取该声明的观点。我已经创建了一个spring引导应用程序,并试图通过GCP云语言客户端jar发送请求

问题:GCP云语言客户端jar无法向google服务发出请求。它将在大约10-15分钟后超时

额外信息:我已经使用python尝试过同样的方法,并且能够很快做到这一点,工作完美无瑕。因此,我可以断定这种联系是存在的,我的信念正在正常发挥作用

项目URLhttps://github.com/chaundhyan/manas-gateway

日志

19:50:25.638 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
Text Received: My Name is Mukul
Document Created: My Name is Mukul
19:50:26.116 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.channel.DefaultChannelId - -Dio.netty.processId: 3109 (auto-detected)
19:50:26.118 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
19:50:26.119 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
19:50:26.121 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.util.NetUtil - Loopback interface: lo0 (lo0, 0:0:0:0:0:0:0:1%lo0)
19:50:26.122 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file /proc/sys/net/core/somaxconn. Default: 128
19:50:26.125 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.channel.DefaultChannelId - -Dio.netty.machineId: a0:99:9b:ff:fe:15:5a:49 (auto-detected)
19:50:26.180 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector@76ed8938
19:50:26.471 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] HANDSHAKEN: protocol:TLSv1.3 cipher suite:TLS_AES_128_GCM_SHA256
19:50:26.476 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] OUTBOUND SETTINGS: ack=false settings={ENABLE_PUSH=0, MAX_CONCURRENT_STREAMS=0, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=8192}
19:50:26.479 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] OUTBOUND WINDOW_UPDATE: streamId=0 windowSizeIncrement=983041
19:50:26.491 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND SETTINGS: ack=false settings={MAX_CONCURRENT_STREAMS=100, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=65536}
19:50:26.492 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] OUTBOUND SETTINGS: ack=true
19:50:26.493 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND WINDOW_UPDATE: streamId=0 windowSizeIncrement=983041
19:50:26.494 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND SETTINGS: ack=true
19:54:26.502 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND GO_AWAY: lastStreamId=2147483647 errorCode=0 length=17 bytes=73657373696f6e5f74696d65645f6f7574
19:54:26.515 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND PING: ack=false bytes=0
19:54:26.515 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] OUTBOUND PING: ack=true bytes=0
19:54:26.525 [grpc-nio-worker-ELG-1-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x5e9a3940, L:/192.168.1.3:51891 - R:language.googleapis.com/142.250.183.74:443] INBOUND GO_AWAY: lastStreamId=0 errorCode=0 length=17 bytes=73657373696f6e5f74696d65645f6f7574
Exception in thread "main" com.google.api.gax.rpc.DeadlineExceededException: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: Deadline exceeded after 599.986342726s. 
    at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:51)
    at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:72)
    at com.google.api.gax.grpc.GrpcApiExceptionFactory.create(GrpcApiExceptionFactory.java:60)
    at com.google.api.gax.grpc.GrpcExceptionCallable$ExceptionTransformingFuture.onFailure(GrpcExceptionCallable.java:97)
    at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:68)
    at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1041)
    at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:30)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1215)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:983)
    at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:771)
    at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:563)
    at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:533)
    at io.grpc.internal.DelayedClientCall$CloseListenerRunnable.runInContext(DelayedClientCall.java:406)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    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.language.v1.LanguageServiceClient.analyzeSentiment(LanguageServiceClient.java:217)
        at com.google.cloud.language.v1.LanguageServiceClient.analyzeSentiment(LanguageServiceClient.java:164)
        at com.mukul.pro.manasgateway.ManasGatewayApplication.main(ManasGatewayApplication.java:22)
Caused by: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: Deadline exceeded after 599.986342726s. 
    at io.grpc.Status.asRuntimeException(Status.java:535)
    ... 10 more

我可以在日志中找到前2个系统。但在那之后,一切都变暗了

String text = "My Name is Mukul";
        try (LanguageServiceClient language = LanguageServiceClient.create()) {
            System.out.println("Text Received: " + text);
            Document doc = Document.newBuilder().setContent(text).setType(Document.Type.PLAIN_TEXT).build();
            System.out.println("Document Created: " + doc.getContent());

            // Detects the sentiment of the text
            Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();
            System.out.println("Got Sentiment: " + sentiment.getScore());
            System.out.printf("Text: %s%n", text);
            System.out.printf("Sentiment: %s, %s%n", sentiment.getScore(), sentiment.getMagnitude());
        }

共 (0) 个答案