2016-12-02 26 views
0

내가클라우드 음성 API 샘플에서 예외가 발생합니다 : java.net.UnknownHostException :에 의한 accounts.google.com

에서 예제 코드 다음 음성을 인식 Google 클라우드 음성 API를 사용하려고 해요

https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/speech/grpc

나는 here에서 설명한대로 지침과 작성된 자격 증명 (서비스 계정 키)을 작성하고 결제 계정을 만들었습니다.

mvn clean install 명령을 실행할 때 테스트 케이스 실행을 시작합니다. 다음과 같은 오류가 발생합니다 :

> Running com.examples.cloud.speech.RecognitionAudioFactoryTest 
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.652 sec - in com.examples.cloud.speech.RecognitionAudioFactory 
Running com.examples.cloud.speech.StreamingRecognizeClientTest 
Dec 01, 2016 11:50:07 PM io.grpc.internal.ManagedChannelImpl <init> 
INFO: [[email protected]] Created with target speech.googleapis.com:443 
WARN - recognize failed: {0} 
io.grpc.StatusRuntimeException: UNAUTHENTICATED 
     at io.grpc.Status.asRuntimeException(Status.java:545) 
     at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:395) 
     at io.grpc.ClientInterceptors$CheckedForwardingClientCall.start(ClientInterceptors.java:203) 
     at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:273) 
     at io.grpc.stub.ClientCalls.asyncStreamingRequestCall(ClientCalls.java:266) 
     at io.grpc.stub.ClientCalls.asyncBidiStreamingCall(ClientCalls.java:109) 
     at com.google.cloud.speech.v1beta1.SpeechGrpc$SpeechStub.streamingRecognize(SpeechGrpc.java:206) 
     at com.examples.cloud.speech.StreamingRecognizeClient.recognize(StreamingRecognizeClient.java:135) 
     at com.examples.cloud.speech.StreamingRecognizeClientTest.test16KHzAudio(StreamingRecognizeClientTest.java:70) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) 
     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 
     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) 
     at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) 
     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 
     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 
     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) 
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) 
     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) 
     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
     at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) 
     at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161) 
     at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290) 
     at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242) 
     at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121) 
Caused by: java.io.IOException: Error getting access token for service account: 
     at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:319) 
     at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:149) 
     at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:135) 
     at io.grpc.auth.ClientAuthInterceptor.getRequestMetadata(ClientAuthInterceptor.java:150) 
     at io.grpc.auth.ClientAuthInterceptor.access$100(ClientAuthInterceptor.java:64) 
     at io.grpc.auth.ClientAuthInterceptor$1.checkedStart(ClientAuthInterceptor.java:96) 
     at io.grpc.ClientInterceptors$CheckedForwardingClientCall.start(ClientInterceptors.java:195) 
     ... 32 more 
Caused by: java.net.UnknownHostException: accounts.google.com 
     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) 
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) 
     at java.net.Socket.connect(Socket.java:579) 
     at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:625) 
     at sun.net.NetworkClient.doConnect(NetworkClient.java:175) 
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) 
     at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) 
     at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275) 
     at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371) 
     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.jav 
     at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:933) 
     at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) 
     at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1092) 
     at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250) 
     at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77) 
     at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965) 
     at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:317) 
     ... 38 more 

당신은 내가 무슨 일이 일어나는지 이해할 수 있도록 도와 줄 수 있습니까?

답변

0

대답을 확인하십시오 here. 프록시 뒤 코드를 실행하고 있는지 확인하거나 jvm에 API 키를 전달하고 있는지 확인하십시오