Google-Cloud:尚未正确配置Jetty ALPN / NPN

在使用Google Pubsub列出主题时获取exception,我的Web应用程序在tomcat上运行。

public static List listTopics(GcpCredentials gcCredentials, String project) throws GCPException, IOException { List topics = new ArrayList(); TopicAdminClient client = getTopicClient(gcCredentials); ProjectName projectName = ProjectName.create(project); ListTopicsPagedResponse response = client.listTopics(projectName); for (Topic topic :response.iterateAll()) { topics.add(topic.getNameAsTopicName().getTopic()); } return topics; }` 

例外:

java.lang.IllegalArgumentException:尚未正确配置Jetty ALPN / NPN。
在io.grpc.net上的io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)(GrpcSslContexts.java:139) )在io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java)的io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335)的io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109) 308)在io.grpc.internal.CallCredentialsApplyingTransportFactory的io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory $ DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499)io.grpc.netty.NettyChannelBuilder $ NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448) .newClientTransport(CallCredentialsApplyingTransportFactory.java:61)位于io.grpc.internal.InternalSubchannel.obtainActive的io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209) 在io.grpc.internal.ManagedChannelImpl $ SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806)的io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568)中运输(InternalSubchannel.java:186)io.grpc.internal .llayedClientTransport.reprocess(DelayedClientTransport.java:296)位于io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)的io.grpc.internal.ManagedChannelImpl $ LbHelperImpl $ 5.run(ManagedChannelImpl.java:724) .grpc.internal.ManagedChannelImpl $ LbHelperImpl.runSerialized(ManagedChannelImpl.java:715)at io.grpc.internal.ManagedChannelImpl $ NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752)at io.grpc.internal.DnsNameResolver $ 1.run(DnsNameResolver。 java:174)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread)的.java:745)

我用Netty版本4.1.15.Final观察到了这个问题,但没有用4.1.13.Final观察到。 检查您的传递依赖项。 即Spring Boot引用Netty。

我添加到POM以使其与Spanner API版本0.22.0-beta一起使用:

4.1.13.Final ... io.netty netty-codec ${v.netty} io.netty netty-codec-http ${v.netty} io.netty netty-codec-http2 ${v.netty} io.netty netty-handler ${v.netty} io.netty netty-common ${v.netty} io.netty netty-handler-proxy ${v.netty} io.netty netty-transport ${v.netty} io.netty netty-resolver ${v.netty} io.netty netty-codec-socks ${v.netty} io.netty netty-buffer ${v.netty}

如果问题仍然存在,或者它不是一个选项,请使用适当的bootclasspath条目运行JVM,如:

java -Xbootclasspath/p:/tmp/alpn-boot-8.1.11.v20170118.jar -cp ...

确保将/tmp/alpn-boot-8.1.11.v20170118.jar替换/tmp/alpn-boot-8.1.11.v20170118.jar与本页列出的JVM版本匹配的alpn jar的位置: https ://www.eclipse.org/jetty/documentation/9.4 。 X / alpn-chapter.html

github上有一个可能的解决方案:“ 配置SSL时出现exception:”Jetty ALPN / NPN未正确配置。 “

建议的步骤,引用上述文件:

1)编辑catalina.sh /usr/local/Cellar/tomcat/8.5.3/libexec/bin/catalina.sh

2)在第103行,添加以下CATALINA_OPTS =“ – javaagent:/Library/Tomcat/lib/jetty-alpn-agent-2.0.6.jar”

3)重启tomcat ../bin/shutdown.sh ../bin/startup.sh