报告 ALPN not available 分两种场景:
第一种场景:初始化 HTTP 2 Client 的时候。 CSE (ServiceComb Java Chassis) 默认会初始化 HTTP 2 Client,方便和启用了 HTTP 2 协议的 Provider 进行通信。
1
2
3
4
5
6
7
8
9
10
11
12
io.vertx.core.VertxException: ALPN not available for JDK SSL/TLS engine
at io.vertx.core.net.impl.SSLHelper.resolveEngineOptions(SSLHelper.java:88)
at io.vertx.core.net.impl.SSLHelper.<init>(SSLHelper.java:134)
at io.vertx.core.http.impl.HttpClientImpl.<init>(HttpClientImpl.java:131)
at io.vertx.core.impl.VertxImpl.createHttpClient(VertxImpl.java:317)
at org.apache.servicecomb.foundation.vertx.client.http.HttpClientPoolFactory.createClientPool(HttpClientPoolFactory.java:36)
at org.apache.servicecomb.foundation.vertx.client.http.HttpClientPoolFactory.createClientPool(HttpClientPoolFactory.java:27)
at org.apache.servicecomb.foundation.vertx.client.ClientPoolManager.createClientPool(ClientPoolManager.java:60)
at org.apache.servicecomb.foundation.vertx.client.ClientVerticle.start(ClientVerticle.java:35)
at io.vertx.core.AbstractVerticle.start(AbstractVerticle.java:106)
at io.vertx.core.Verticle.start(Verticle.java:66)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556)
这种场景报告的错误在没有使用 HTTP 2 的情况下都可以忽略,不用处理。可以通过下面的配置项关闭 HTTP2 客户端的 ALPN:
servicecomb.rest.client.http2.useAlpnEnabled: false
如果使用 servicecomb-java-chassis 2.0.2 及其以上版本,还可以使用如下配置项,不初始化 HTTP 2客户端。
servicecomb.rest.client.http2.enabled: false
第二种场景:初始化 HTTP 2 Server 的时候。 CSE (ServiceComb Java Chassis) 默认不会启用 HTTP 2 Server。 用户需要通过配置项开启 HTTP2, 分为 H2 和 H2C两种模式, 如果使用 H2 模式 ( SSL),必须开启ALPN, 可能报告如下错误。 启用 H2 的配置参考: https://docs.servicecomb.io/java-chassis/zh_CN/transports/http2/
1
2
3
4
5
6
7
8
9
io.vertx.core.VertxException: ALPN not available for JDK SSL/TLS engine
at io.vertx.core.net.impl.SSLHelper.resolveEngineOptions(SSLHelper.java:88)
at io.vertx.core.net.impl.SSLHelper.<init>(SSLHelper.java:155)
at io.vertx.core.http.impl.HttpServerImpl.<init>(HttpServerImpl.java:93)
at io.vertx.core.impl.VertxImpl.createHttpServer(VertxImpl.java:308)
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.createHttpServer(RestServerVerticle.java:247)
at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:99)
at io.vertx.core.Verticle.start(Verticle.java:66)
at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556)
如果使用 H2C 模式, 不需要启用 ALPN,可以通过下面的配置项关闭:
servicecomb:
server:
http2:
useAlpnEnabled: false
CSE 提供两种方式使用 ALPN, 第一种是 openssl, 第二种是 JDK 原生 SSL。 默认使用原生 SSL, 使用 openssl 需要加上下面的配置项:
1
ssl.engine: openssl
* netty 和 boringssl 版本不匹配。或者 netty-tcnative-boringssl-static-.jar 没有包含对应操作系统的库文件,比如 ARM 环境。 CSE 3.0.0 版本在 foundation-auth 模块包含了 ARM 版本的库文件, 其他环境的库文件在 netty-tcnative-boringssl-static-.jar 压缩包中。
* 操作系统 openssl 版本过低也可能导致这个问题。
* alpn 和 JDK 的版本不匹配,或者没有正确使用安装 ALPN 包。 CSE 默认没有携带 ALPN 包, 需要开发者自行配置。 参考: https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions 获取 JDK的对应版本;参考: https://github.com/Blazemeter/jmeter-http2-plugin/blob/master/README.md 了解如何配置。
* 本机的JDK版本和操作系统版本位数不一样
如果使用 HTTP2, 并且没有启用 TLS:
servicecomb: rest: address: 0.0.0.0:8080?protocol=http2
报告如下错误:
2020-04-08 01:42:09,390 [ERROR] org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:123)io.vertx.core.VertxException: ALPN not available for JDK SSL/TLS engine at io.vertx.core.net.impl.SSLHelper.resolveEngineOptions(SSLHelper.java:88) at io.vertx.core.net.impl.SSLHelper.<init>(SSLHelper.java:155) at io.vertx.core.http.impl.HttpServerImpl.<init>(HttpServerImpl.java:93) at io.vertx.core.impl.VertxImpl.createHttpServer(VertxImpl.java:308) at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.createHttpServer(RestServerVerticle.java:247) at org.apache.servicecomb.transport.rest.vertx.RestServerVerticle.start(RestServerVerticle.java:99) at io.vertx.core.Verticle.start(Verticle.java:66) at io.vertx.core.impl.DeploymentManager.lambda$doDeploy$8(DeploymentManager.java:556) at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369) at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)
没开启 TLS 的情况下, 不需要开启 ALPN, 增加如下配置项即可:
servicecomb: server: http2: useAlpnEnabled: false
当不需要访问 HTTP2 协议的服务端时,可以关闭 HTTP2 客户端的 ALPN:
servicecomb.rest.client.http2.useAlpnEnabled: false
如果使用 servicecomb-java-chassis 2.0.2 及其以上版本,还可以使用如下配置项,不初始化 HTTP 2客户端。
servicecomb.rest.client.http2.enabled: false
原网址: 访问
创建于: 2021-09-08 18:25:19
目录: default
标签: 无
未标明原创文章均为采集,版权归作者所有,转载无需和我联系,请注明原出处,南摩阿彌陀佛,知识,不只知道,要得到
最新评论