Hi There, Could Someone help please. PubSub and BQ are working from same environment but only cloud translation while using client library giving alpn issue.
Authentication Method : ADC ------ Maven Dependency***************************************** <dependencyManagement> <dependencies> <dependency> <groupId>com.google.cloud</groupId> <artifactId>libraries-bom</artifactId> <version>26.2.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- Here are all your dependencies. Currently only one. These are automatically downloaded from https://mvnrepository.com/ --> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-translate</artifactId> <!-- <version>2.8.0</version> --> </dependency> </dependencies> ------ Java Class***************************************** package gcp.translation; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; // [START translate_v3_translate_text] // [START translate_v3_translate_text_0] // Imports the Google Cloud Translation library. import com.google.cloud.translate.v3.LocationName; import com.google.cloud.translate.v3.TranslateTextRequest; import com.google.cloud.translate.v3.TranslateTextResponse; import com.google.cloud.translate.v3.Translation; import com.google.cloud.translate.v3.TranslationServiceClient; import com.google.cloud.translate.v3.TranslationServiceSettings; import io.grpc.Channel; import io.grpc.ChannelCredentials; import io.grpc.ClientInterceptor; import io.grpc.ClientInterceptors; import io.grpc.Grpc; import io.grpc.ManagedChannel; import io.grpc.TlsChannelCredentials; // [END translate_v3_translate_text_0] public class TranslateText { public static void main(String args[]) throws Exception { translateText(); } // [START translate_v3_translate_text_1] // Set and pass variables to overloaded translateText() method for translation. public static void translateText() throws IOException { // TODO(developer): Replace these variables before running the sample. String projectId = "gcp-spsf-dev"; // Supported Languages: https://cloud.google.com/translate/docs/languages String targetLanguage = "hi"; String text = "Hello Danial, How are you?"; System.out.println("Calling translaton"); translateText(projectId, targetLanguage, text); } // [END translate_v3_translate_text_1] // [START translate_v3_translate_text_2] // Translate text to target language. public static void translateText(String projectId, String targetLanguage, String text) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call // the "close" method on the client to safely clean up any remaining background resources. TranslationServiceSettings tsSettings = TranslationServiceSettings.newBuilder() //.setEndpoint("proxy.ups.com:443") //.setEndpoint("translate-u.p.googleapis.com:443") //.setEndpoint("localhost:443") //.setCredentialsProvider(FixedCredentialsProvider .build(); TranslationServiceClient translationServiceClient = TranslationServiceClient.create(tsSettings); //try (TranslationServiceClient client = TranslationServiceClient.create()) { try (TranslationServiceClient client = translationServiceClient) { // Supported Locations: `global`, [glossary location], or [model location] // Glossaries must be hosted in `us-central1` // Custom Models must use the same location as your model. (us-central1) LocationName parent = LocationName.of(projectId, "global"); /* * ChannelCredentials credentials; credentials = * TlsChannelCredentials.newBuilder() .trustManager(new * File("<path-to-file>/cacert.pem")) .build(); ManagedChannel originChannel = * Grpc.newChannelBuilderForAddress("proxy.ups.com", 8080, credentials).build(); * ClientInterceptor interceptor = new HeaderClientInterceptor(); Channel * channel = ClientInterceptors.intercept(originChannel, interceptor); * * stub = LogStreamerGrpc.newStub(channel); */ // Supported Mime Types: https://cloud.google.com/translate/docs/supported-formats TranslateTextRequest request = TranslateTextRequest.newBuilder() .setParent(parent.toString()) .setMimeType("text/plain") .setTargetLanguageCode(targetLanguage) .addContents(text) .build(); TranslateTextResponse response = client.translateText(request); // Display the translation for each input text provided for (Translation translation : response.getTranslationsList()) { System.out.printf("Translated text: %s\n", translation.getTranslatedText()); } } } // [END translate_v3_translate_text_2] } // [END translate_v3_translate_text] --------- Exception******************************************** exception in thread "main" com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed ALPN negotiation: Unable to find compatible protocol Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:112) 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:67) at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1132) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270) at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1038) at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:808) at io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:574) at io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:544) 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:535) at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:471) at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:435) at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:468) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:563) at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:744) 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.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) 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.translate.v3.TranslationServiceClient.translateText(TranslationServiceClient.java:485) at gcp.translation.TranslateText.translateText(TranslateText.java:131) at gcp.translation.TranslateText.translateText(TranslateText.java:83) at gcp.translation.TranslateText.main(TranslateText.java:71) Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed ALPN negotiation: Unable to find compatible protocol Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] at io.grpc.Status.asRuntimeException(Status.java:539) ... 17 more -------------------- openssl s_client -CAfile fresh-cert.pem -connect googleapis.com:443 -alpn h2 -proxy proxy-name:port result************************************************** -----END CERTIFICATE----- subject=CN = googleapis.com issuer=C = US, ST = New Jersey, L = Mahwah, O = "United Parcel Service, Inc.", CN = UPSProxyCA --- No client certificate CA names sent Peer signing digest: SHA256 Peer signature type: RSA-PSS Server Temp Key: X25519, 253 bits --- SSL handshake has read 8825 bytes and written 478 bytes Verification: OK --- New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384 Server public key is 2048 bit Secure Renegotiation IS NOT supported Compression: NONE Expansion: NONE ALPN protocol: h2 Early data was not sent Verify return code: 0 (ok) --- On Wednesday, January 18, 2023 at 1:21:17 PM UTC-5 Anil Kumar wrote: > Hi There, > while calling to google cloud translation api by using sample java google > cloud client library, I am getting below exception with jdk8u341 version : > > Could you please help? > --- > > com.google.api.gax.rpc.UnavailableException: > io.grpc.StatusRuntimeException: UNAVAILABLE: Failed ALPN negotiation: > Unable to find compatible protocol > Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, > WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] > at > com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:112) > 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:67) > at > com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1132) > at > com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) > at > com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270) > at > com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1038) > at > com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:808) > at > io.grpc.stub.ClientCalls$GrpcFuture.setException(ClientCalls.java:574) > at > io.grpc.stub.ClientCalls$UnaryStreamToFuture.onClose(ClientCalls.java:544) > 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:535) > at > io.grpc.internal.DelayedClientCall$DelayedListener$3.run(DelayedClientCall.java:470) > at > io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(DelayedClientCall.java:434) > at > io.grpc.internal.DelayedClientCall$DelayedListener.onClose(DelayedClientCall.java:467) > at > io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:563) > at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:70) > at > io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(ClientCallImpl.java:744) > 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.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.translate.v3.TranslationServiceClient.translateText(TranslationServiceClient.java:488) > at > com.ups.google.translation.service.TranslateServiceAdvanced.translateTextWithPassedADC(TranslateServiceAdvanced.java:130) > at > com.ups.google.translation.service.TranslateServiceAdvanced.translateText(TranslateServiceAdvanced.java:61) > at > com.ups.google.translation.LocalUnitTest.testTranslation(LocalUnitTest.java:36) > at com.ups.google.translation.SpringApp.main(SpringApp.java:15) > Caused by: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed ALPN > negotiation: Unable to find compatible protocol > Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, > WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] > at io.grpc.Status.asRuntimeException(Status.java:535) > ... 17 more > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e7f7eab2-b8ec-4cba-867a-b03670707addn%40googlegroups.com.