使用google texttospeech时出错:找不到TLS ALPN提供程序;没有可用的netty-tcnative,Conscrypt或Jetty NPN / ALPN

问题描述 投票:0回答:2

使用GGoogle Text to Speech API时遇到以下异常,

java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available
    at i.g.n.s.io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:233)
    at i.g.n.s.io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:144)
    at i.g.n.s.io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:93)
    at i.g.n.s.i.grpc.netty.NettyChannelBuilder.buildTransportFactory(NettyChannelBuilder.java:397)
    at i.g.i.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:513)
    at c.g.a.g.g.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:304)
    at c.g.a.g.g.InstantiatingGrpcChannelProvider.access$1500(InstantiatingGrpcChannelProvider.java:71)
    at c.g.a.g.g.InstantiatingGrpcChannelProvider$1.createSingleChannel(InstantiatingGrpcChannelProvider.java:202)
    at com.google.api.gax.grpc.ChannelPool.create(ChannelPool.java:72)
    at c.g.a.g.g.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:209)
    at c.g.a.g.g.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:192)
    at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:155)
    at c.g.c.t.v1.stub.GrpcTextToSpeechStub.create(GrpcTextToSpeechStub.java:74)
    at c.g.c.t.v1.stub.TextToSpeechStubSettings.createStub(TextToSpeechStubSettings.java:100)
    at c.g.c.texttospeech.v1.TextToSpeechClient.<init>(TextToSpeechClient.java:128)
    at c.g.c.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:109)
    at c.g.c.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
    at com.vxml.util.GoogleTTSUtil.getSpeech(GoogleTTSUtil.scala:11)
    at com.vxml.util.GoogleTTSUtil.getSpeech$(GoogleTTSUtil.scala:10)
    at com.VxmlActivitiesMain$.getSpeech(VxmlActivitiesMain.scala:22)
    at com.vxml.rest.TTSRoute.$anonfun$ttsRoute$2(TTSRoute.scala:35)
    at akka.http.scaladsl.server.Directive$.$anonfun$addByNameNullaryApply$2(...

使用了以下sbt依赖项,

  val googleTTS              = "com.google.cloud" % "google-cloud-texttospeech"       % "1.0.2"
  val googleLibraries        = "com.google.cloud" % "libraries-bom"                   % "4.4.1"
  val googleGrpc             = "com.google.api"   % "gax-grpc"                        % "1.56.0"
  val nettyShaded            = "io.grpc"          % "grpc-netty-shaded"               % "1.28.1"
  val nettyTcnativeBoringSsl = "io.netty"         % "netty-tcnative-boringssl-static" % "2.0.20.Final"

使用的Docker基础映像:openjdk:8u212-jdk-alpine

java netty grpc google-text-to-speech
2个回答
0
投票

此链接https://github.com/grpc/grpc-java/blob/master/SECURITY.md#netty说:

io.grpc:grpc-netty-shaded包含正确版本的Netty和netty-tcnative-boringssl-static,不会与其他Netty用法冲突。

您可以尝试删除自己的nettyTcnativeBoringSsl依赖项,看看是否能解决问题?


0
投票

在IllegalStateException之前,gRPC will dump log messages with additional info。因此,最好的办法是查看这些消息并确定正在发生的事情。

但是,由于您在Alpine上运行,我希望问题是Error loading shared library libcrypt.so.1: No such file or directory。缺省情况下,Alpine与glibc缺乏兼容性的gRPC mentions in its security documentation,可以通过安装以下软件包来恢复兼容性:apk update && apk add libc6-compat。此问题是由Linux上通常使用的glibc和Alpine上使用的musl之间的差异引起的。

© www.soinside.com 2019 - 2024. All rights reserved.