谷歌愿景OCR api没有回复

时间:2018-06-01 11:06:16

标签: google-vision

我从一个spring boot maven项目调用google vision OCR api来从图像中提取文本。

public class TestGoogleVision {

BufferedWriter writer = null;

public static void main(String args[]) throws IOException, Exception {
    List<String> output=new ArrayList<>();

 GoogleCredentials credentials = ServiceAccountCredentials.fromStream(new FileInputStream("/Users/ummulkiram 1/Documents/UK.json"))
           .createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));

    ImageAnnotatorSettings settings =
            ImageAnnotatorSettings.newBuilder().setCredentialsProvider
                    (FixedCredentialsProvider.create(credentials)).build();

    System.out.println("Setting::::::::" + settings);

    try (ImageAnnotatorClient vision = ImageAnnotatorClient.create(settings)) {

        System.out.println("CLIENT::::::: " + vision);
        List<AnnotateImageRequest> requests = new ArrayList<>();
        Feature feat = Feature.newBuilder().setType(Type.TEXT_DETECTION).build();

        String[] fileNames = {"/Users/ummulkiram 1/Documents/img.jpg"};


        for(String fileName : fileNames) {

            // Reads the image file into memory
            Path path = Paths.get(fileName);
            byte[] data = Files.readAllBytes(path);
            ByteString imgBytes = ByteString.copyFrom(data);

            // Builds the image annotation request

            Image img = Image.newBuilder().setContent(imgBytes).build();

            AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
            requests.add(request);
        }

        // Performs text detection on the image file
        System.out.println("line 80");
        BatchAnnotateImagesResponse response = vision.batchAnnotateImages(requests);
        System.out.println("line 82");
        List<AnnotateImageResponse> responses = response.getResponsesList();

        for (AnnotateImageResponse resp : responses) {
            if (resp.hasError()) {
                System.out.printf("Error: %s\n", resp.getError().getMessage());
                return;
            }
            if (resp.getTextAnnotationsList() != null) {
                int count = 0;
                System.out.println("List size"+resp.getTextAnnotationsList().size());
                //writer = new BufferedWriter(new FileWriter("CHOLA MS GEN INSURANCE", true));
                for (EntityAnnotation ea : resp.getTextAnnotationsList()) {
                    output.add(ea.getDescription());
                    System.out.println(ea.getDescription());

                    System.out.println("XXXXXXXXX");

                    break;
                }
            }
        }
    }
    System.out.println(output);
}
}

下面一行(即第80行以下)的电话不会回复。

BatchAnnotateImagesResponse response = vision.batchAnnotateImages(requests);

它会在很长一段时间内停滞不前,然后抛出以下异常。

a Caused by: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded: -538368540044 ns from now
at io.grpc.Status.asRuntimeException(Status.java:526)

控制台打印了以下日志。请帮我解决这个问题。

    /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=55016:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/lib/tools.jar:/Users/ummulkiram 1/development/TestApp/target/classes:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.5.3.RELEASE/spring-boot-starter-web-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.3.RELEASE/spring-boot-starter-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot/1.5.3.RELEASE/spring-boot-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.3.RELEASE/spring-boot-autoconfigure-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.3.RELEASE/spring-boot-starter-logging-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar:/Users/ummulkiram 1/.m2/repository/ch/qos/logback/logback-core/1.1.11/logback-core-1.1.11.jar:/Users/ummulkiram 1/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.25/jcl-over-slf4j-1.7.25.jar:/Users/ummulkiram 1/.m2/repository/org/slf4j/jul-to-slf4j/1.7.25/jul-to-slf4j-1.7.25.jar:/Users/ummulkiram 1/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.25/log4j-over-slf4j-1.7.25.jar:/Users/ummulkiram 1/.m2/repository/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.5.3.RELEASE/spring-boot-starter-tomcat-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.14/tomcat-embed-core-8.5.14.jar:/Users/ummulkiram 1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.5.14/tomcat-embed-el-8.5.14.jar:/Users/ummulkiram 1/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.5.14/tomcat-embed-websocket-8.5.14.jar:/Users/ummulkiram 1/.m2/repository/org/hibernate/hibernate-validator/5.3.5.Final/hibernate-validator-5.3.5.Final.jar:/Users/ummulkiram 1/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar:/Users/ummulkiram 1/.m2/repository/org/jboss/logging/jboss-logging/3.3.1.Final/jboss-logging-3.3.1.Final.jar:/Users/ummulkiram 1/.m2/repository/com/fasterxml/classmate/1.3.3/classmate-1.3.3.jar:/Users/ummulkiram 1/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.8.8/jackson-databind-2.8.8.jar:/Users/ummulkiram 1/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.8.0/jackson-annotations-2.8.0.jar:/Users/ummulkiram 1/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.8.8/jackson-core-2.8.8.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-web/4.3.8.RELEASE/spring-web-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-aop/4.3.8.RELEASE/spring-aop-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-beans/4.3.8.RELEASE/spring-beans-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-context/4.3.8.RELEASE/spring-context-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-webmvc/4.3.8.RELEASE/spring-webmvc-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-expression/4.3.8.RELEASE/spring-expression-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.5.3.RELEASE/spring-boot-starter-jdbc-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.5.14/tomcat-jdbc-8.5.14.jar:/Users/ummulkiram 1/.m2/repository/org/apache/tomcat/tomcat-juli/8.5.14/tomcat-juli-8.5.14.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-jdbc/4.3.8.RELEASE/spring-jdbc-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-tx/4.3.8.RELEASE/spring-tx-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/com/h2database/h2/1.4.194/h2-1.4.194.jar:/Users/ummulkiram 1/.m2/repository/org/bgee/log4jdbc-log4j2/log4jdbc-log4j2-jdbc4.1/1.16/log4jdbc-log4j2-jdbc4.1-1.16.jar:/Users/ummulkiram 1/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/spring-core/4.3.8.RELEASE/spring-core-4.3.8.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar:/Users/ummulkiram 1/.m2/repository/org/apache/httpcomponents/httpcore/4.4.6/httpcore-4.4.6.jar:/Users/ummulkiram 1/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/Users/ummulkiram 1/.m2/repository/com/google/cloud/google-cloud-vision/1.31.0/google-cloud-vision-1.31.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/cloud/google-cloud-core/1.31.0/google-cloud-core-1.31.0.jar:/Users/ummulkiram 1/.m2/repository/joda-time/joda-time/2.9.9/joda-time-2.9.9.jar:/Users/ummulkiram 1/.m2/repository/com/google/http-client/google-http-client/1.23.0/google-http-client-1.23.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/api-common/1.5.0/api-common-1.5.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/gax/1.25.0/gax-1.25.0.jar:/Users/ummulkiram 1/.m2/repository/org/threeten/threetenbp/1.3.3/threetenbp-1.3.3.jar:/Users/ummulkiram 1/.m2/repository/com/google/auth/google-auth-library-oauth2-http/0.9.1/google-auth-library-oauth2-http-0.9.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/http-client/google-http-client-jackson2/1.19.0/google-http-client-jackson2-1.19.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/protobuf/protobuf-java-util/3.5.1/protobuf-java-util-3.5.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/grpc/proto-google-common-protos/1.11.0/proto-google-common-protos-1.11.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/grpc/proto-google-iam-v1/0.12.0/proto-google-iam-v1-0.12.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/cloud/google-cloud-core-grpc/1.31.0/google-cloud-core-grpc-1.31.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/auth/google-auth-library-credentials/0.9.1/google-auth-library-credentials-0.9.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/protobuf/protobuf-java/3.5.1/protobuf-java-3.5.1.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-protobuf/1.10.1/grpc-protobuf-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-protobuf-lite/1.10.1/grpc-protobuf-lite-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-context/1.10.1/grpc-context-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/gax-grpc/1.25.0/gax-grpc-1.25.0.jar:/Users/ummulkiram 1/.m2/repository/com/google/api/grpc/proto-google-cloud-vision-v1/1.13.0/proto-google-cloud-vision-v1-1.13.0.jar:/Users/ummulkiram  1/.m2/repository/io/grpc/grpc-netty-shaded/1.10.1/grpc-netty-shaded-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-core/1.10.1/grpc-core-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/errorprone/error_prone_annotations/2.1.2/error_prone_annotations-2.1.2.jar:/Users/ummulkiram 1/.m2/repository/io/opencensus/opencensus-api/0.11.0/opencensus-api-0.11.0.jar:/Users/ummulkiram 1/.m2/repository/io/opencensus/opencensus-contrib-grpc-metrics/0.11.0/opencensus-contrib-grpc-metrics-0.11.0.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-stub/1.10.1/grpc-stub-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/io/grpc/grpc-auth/1.10.1/grpc-auth-1.10.1.jar:/Users/ummulkiram 1/.m2/repository/com/google/guava/guava/21.0/guava-21.0.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.5.3.RELEASE/spring-boot-starter-actuator-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/boot/spring-boot-actuator/1.5.3.RELEASE/spring-boot-actuator-1.5.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/cloud/spring-cloud-starter/1.2.2.RELEASE/spring-cloud-starter-1.2.2.RELEASE.jar:/Users/ummulkiram  1/.m2/repository/org/springframework/security/spring-security-crypto/4.2.2.RELEASE/spring-security-crypto-4.2.2.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/cloud/spring-cloud-commons/1.2.2.RELEASE/spring-cloud-commons-1.2.2.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/springframework/security/spring-security-rsa/1.0.3.RELEASE/spring-security-rsa-1.0.3.RELEASE.jar:/Users/ummulkiram 1/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.55/bcpkix-jdk15on-1.55.jar:/Users/ummulkiram 1/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.55/bcprov-jdk15on-1.55.jar:/Users/ummulkiram 1/.m2/repository/org/assertj/assertj-core/2.6.0/assertj-core-2.6.0.jar:/Users/ummulkiram 1/.m2/repository/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar" com.bayview.TestGoogleVision
inpstream::::::::java.io.BufferedInputStream@1de0aca6
Setting::::::::ImageAnnotatorSettings{executorProvider=InstantiatingExecutorProvider{executorThreadCount=4}, transportChannelProvider=com.google.api.gax.grpc.InstantiatingGrpcChannelProvider@59e84876, credentialsProvider=FixedCredentialsProvider{credentials=ServiceAccountCredentials{clientId=103654972067458963122, clientEmail=uk-974@spherical-gate-204306.iam.gserviceaccount.com, privateKeyId=e053f4b02858a4389953cdfefe2d3321edc19952, transportFactoryClassName=com.google.auth.oauth2.OAuth2Utils$DefaultHttpTransportFactory, tokenServerUri=https://accounts.google.com/o/oauth2/token, scopes=[https://www.googleapis.com/auth/cloud-platform], serviceAccountUser=null}}, headerProvider=com.google.api.gax.rpc.NoHeaderProvider@61a485d2, internalHeaderProvider=com.google.api.gax.rpc.ApiClientHeaderProvider@39fb3ab6, clock=com.google.api.core.NanoClock@6276ae34, endpoint=vision.googleapis.com:443, watchdogProvider=com.google.api.gax.rpc.InstantiatingWatchdogProvider@7946e1f4, watchdogCheckInterval=PT10S}
14:15:54.181 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
14:15:54.201 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - Platform: MacOS
14:15:54.202 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
14:15:54.204 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - Java version: 8
14:15:54.207 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
14:15:54.207 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
14:15:54.207 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
14:15:54.207 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: /var/folders/2n/dp_swhjs5mqb17cn0vr33yq00000gq/T (java.io.tmpdir)
14:15:54.207 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
14:15:54.209 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
14:15:54.209 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 3817865216 bytes
14:15:54.209 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
14:15:54.210 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
14:15:54.211 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.workdir: /var/folders/2n/dp_swhjs5mqb17cn0vr33yq00000gq/T (io.netty.tmpdir)
14:15:54.214 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader - Unable to load the library 'io_grpc_netty_shaded_netty_tcnative_osx_x86_64', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no io_grpc_netty_shaded_netty_tcnative_osx_x86_64 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
    at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
    at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:421)
    at io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:89)
    at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:155)
    at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:147)
    at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:151)
    at com.google.cloud.vision.v1.stub.GrpcImageAnnotatorStub.create(GrpcImageAnnotatorStub.java:84)
    at com.google.cloud.vision.v1.stub.ImageAnnotatorStubSettings.createStub(ImageAnnotatorStubSettings.java:120)
    at com.google.cloud.vision.v1.ImageAnnotatorClient.<init>(ImageAnnotatorClient.java:136)
    at com.google.cloud.vision.v1.ImageAnnotatorClient.create(ImageAnnotatorClient.java:117)
    at com.bayview.TestGoogleVision.main(TestGoogleVision.java:57)
    Suppressed: java.lang.UnsatisfiedLinkError: no io_grpc_netty_shaded_netty_tcnative_osx_x86_64 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
        at java.lang.Runtime.loadLibrary0(Runtime.java:870)
        at java.lang.System.loadLibrary(System.java:1122)
        at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
        at java.security.AccessController.doPrivileged(Native Method)
        at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
        at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
        ... 21 common frames omitted
14:15:54.241 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader - Successfully loaded the library /var/folders/2n/dp_swhjs5mqb17cn0vr33yq00000gq/T/libio_grpc_netty_shaded_netty_tcnative_osx_x86_649072795634898251757.dylib
14:15:54.241 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl - netty-tcnative using native library: BoringSSL
14:15:54.364 [main] DEBUG io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector - -Dio.grpc.netty.shaded.io.netty.leakDetection.level: simple
14:15:54.377 [main] DEBUG io.grpc.netty.shaded.io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector@3b2cf7ab
14:15:54.390 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
14:15:54.446 [main] DEBUG io.grpc.netty.shaded.io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector@147ed70f
14:15:54.517 [main] DEBUG io.grpc.netty.shaded.io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 32768
14:15:54.517 [main] DEBUG io.grpc.netty.shaded.io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
14:15:54.517 [main] DEBUG io.grpc.netty.shaded.io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
14:15:54.567 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.CipherSuiteConverter - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-ECDSA-CHACHA20-POLY1305
14:15:54.567 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.CipherSuiteConverter - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 => ECDHE-ECDSA-CHACHA20-POLY1305
14:15:54.568 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.CipherSuiteConverter - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 => ECDHE-RSA-AES128-SHA256
c.netty.shaded.io.netty.handler.ssl.CipherSuiteConverter - Cipher suite mapping: TLS_PSK_WITH_AES_128_CBC_SHA => PSK-AES128-CBC-SHA
14:15:54.572 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl - Supported protocols (OpenSSL): [[SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2]] 
14:15:54.572 [main] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.OpenSsl - Default cipher suites (OpenSSL): [TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,  TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA]
14:15:54.727 [main] DEBUG io.grpc.netty.shaded.io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 16
14:15:54.761 [main] DEBUG io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
14:15:54.761 [main] DEBUG io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
14:15:54.772 [main] DEBUG io.grpc.netty.shaded.io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
CLIENT::::::: com.google.cloud.vision.v1.ImageAnnotatorClient@55b53d44
line 80
14:15:55.202 [grpc-default-executor-0] DEBUG io.grpc.netty.shaded.io.netty.channel.DefaultChannelId - -Dio.netty.processId: 62389 (auto-detected)
14:15:55.206 [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)
14:15:55.207 [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
14:15:55.275 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.grpc.netty.shaded.io.netty.util.ResourceLeakDetector@7d6a4305
14:15:55.637 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.netty.handler.ssl.SslHandler - [id: 0x028b11ee, L:/192.168.1.101:55036 - R:vision.googleapis.com/172.217.160.170:443] HANDSHAKEN: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
14:15:55.650 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x028b11ee, L:/192.168.1.101:55036 - R:vision.googleapis.com/172.217.160.170:443] OUTBOUND SETTINGS: ack=false settings={ENABLE_PUSH=0, MAX_CONCURRENT_STREAMS=0, INITIAL_WINDOW_SIZE=1048576, MAX_HEADER_LIST_SIZE=8192}
14:15:55.651 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x028b11ee, L:/192.168.1.101:55036 - R:vision.googleapis.com/172.217.160.170:443] OUTBOUND WINDOW_UPDATE: streamId=0 windowSizeIncrement=983041
14:15:55.703 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x028b11ee, L:/192.168.1.101:55036 - R:vision.googleapis.com/172.217.160.170:443] INBOUND SETTINGS: ack=true
14:19:55.643 [grpc-default-worker-ELG-2-3] DEBUG io.grpc.netty.shaded.io.grpc.netty.NettyClientHandler - [id: 0x028b11ee, L:/192.168.1.101:55036 - R:vision.googleapis.com/172.217.160.170: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: -538368540044 ns from now
    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:95)
    at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:61)
    at com.google.common.util.concurrent.Futures$4.run(Futures.java:1126)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:902)
    at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:813)
    at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:677)
    at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:492)
    at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:467)
    at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
    at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:684)
    at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41)
    at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:391)
    at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:475)
    at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:557)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:478)
    at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:590)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123)
    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)
Caused by: io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED: deadline exceeded: -538368540044 ns from now
    at io.grpc.Status.asRuntimeException(Status.java:526)
    ... 19 more

Process finished with exit code 1

1 个答案:

答案 0 :(得分:0)

我在Java google-cloud-vision库的1.31.0和1.32.0版本中看到了相同的行为。在函数未返回期间来自jvisualvm的堆栈跟踪如下所示。我无法从谷歌云控制台看到任何来自谷歌收到请求的证据。我必须强制我的Clojure世界明确链接到io.grpc / grpc-core版本1.10.1和guava 25.1-jre;默认的Leiningen行为导致我(我认为)从一些缺少MoreObjects类的继承依赖项中得到一个旧的guava。

"nREPL-worker-0" #23 daemon prio=5 os_prio=0 tid=0x00007f2728005800 nid=0x3cc5 waiting on condition [0x00007f2732bee000] java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x0000000748832b68> (a com.google.api.gax.retrying.CallbackChainRetryingFuture) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:497) at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:196) at com.google.common.util.concurrent.Futures.getUnchecked(Futures.java:1538) at com.google.api.gax.rpc.ApiExceptions.callAndTranslateApiException(ApiExceptions.java:52) at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112) at com.google.cloud.vision.v1.ImageAnnotatorClient.batchAnnotateImages(ImageAnnotatorClient.java:211) at com.google.cloud.vision.v1.ImageAnnotatorClient.batchAnnotateImages(ImageAnnotatorClient.java:187) at i2kworkers.parsers.google_ocr$annotate_image.invoke(google_ocr.clj:59) at i2kworkers.main$eval2822.invoke(form-init1067454995458380652.clj:1) at clojure.lang.Compiler.eval(Compiler.java:6703) at clojure.lang.Compiler.eval(Compiler.java:6666) at clojure.core$eval.invoke(core.clj:2927) at clojure.main$repl$read_eval_print__6625$fn__6628.invoke(main.clj:239) at clojure.main$repl$read_eval_print__6625.invoke(main.clj:239) at clojure.main$repl$fn__6634.invoke(main.clj:257) at clojure.main$repl.doInvoke(main.clj:257) at clojure.lang.RestFn.invoke(RestFn.java:1523) at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__2211.invoke(interruptible_eval.clj:72) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144) at clojure.core$apply.invoke(core.clj:624) at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1862) at clojure.lang.RestFn.invoke(RestFn.java:425) at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:56) at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__2253$fn__2256.invoke(interruptible_eval.clj:191) at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__2248.invoke(interruptible_eval.clj:159) at clojure.lang.AFn.run(AFn.java:22) 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) Locked ownable synchronizers: - <0x00000005cc9fea98> (a java.util.concurrent.ThreadPoolExecutor$Worker)