ServiceComb/CSE服务启动报告错误 ALPN not available

 

问题背景和描述

 

报告 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

 

  • 在使用 opensssl 时可能的原因

 

* netty 和 boringssl 版本不匹配。或者 netty-tcnative-boringssl-static-*.jar 没有包含对应操作系统的库文件,比如 ARM 环境。 CSE 3.0.0 版本在 foundation-auth 模块包含了 ARM 版本的库文件, 其他环境的库文件在 netty-tcnative-boringssl-static-*.jar 压缩包中。 

* 操作系统 openssl 版本过低也可能导致这个问题。 

 

  • 使用 JDK 原生 SSL 时可能的原因

 

* 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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值