首页 > 解决方案 > Netty HTTP/2 客户端在连接到 https://http2.golang.org/ 时失败

问题描述

我对 Netty 很陌生,我还在学习基础知识。作为我正在运行的实验的一部分,我决定采用 Http2Client 示例(https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/http2/ helloworld/client/Http2Client.java)并尝试连接到https://http2.golang.org/

但是,这导致了以下错误:

.............. io.netty.handler.ssl.ApplicationProtocolNegotiationHandler handshakeFailure
WARNING: [id: 0xb57e60d4, L:/[MY-IP-IS-HERE]:59092 - R:http2.golang.org/130.211.116.44:443] TLS handshake failed:
javax.net.ssl.SSLHandshakeException: error:10000438:SSL routines:OPENSSL_internal:TLSV1_ALERT_INTERNAL_ERROR
    at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.shutdownWithError(ReferenceCountedOpenSslEngine.java:897)
    at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.sslReadErrorResult(ReferenceCountedOpenSslEngine.java:1147)
    at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1101)
    at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1169)
    at io.netty.handler.ssl.ReferenceCountedOpenSslEngine.unwrap(ReferenceCountedOpenSslEngine.java:1212)
    at io.netty.handler.ssl.SslHandler$SslEngineType$1.unwrap(SslHandler.java:216)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1297)
    at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1211)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1245)
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:502)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:441)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:278)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

我在 Maven pom 中有以下依赖项:

  <dependency>
     <groupId>io.netty</groupId>
     <artifactId>netty-handler</artifactId>
     <version>4.1.30.Final</version>
  </dependency>
  <dependency>
     <groupId>io.netty</groupId>
     <artifactId>netty-codec-http</artifactId>
     <version>4.1.30.Final</version>
  </dependency>
  <dependency>
     <groupId>io.netty</groupId>
     <artifactId>netty-codec-http2</artifactId>
     <version>4.1.30.Final</version>
  </dependency>
  <dependency>
     <groupId>io.netty</groupId>
     <artifactId>netty-tcnative-boringssl-static</artifactId>
     <version>2.0.19.Final</version>
     <classifier>${os.detected.classifier}</classifier>
     <optional>true</optional>
  </dependency>

${os.detected.classifier}解决为windows-x86_64

顺便说一句,当我将示例 Http2Client 连接到示例 Http2Server 时,一切正常(https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/http2/helloworld /server/Http2Server.java)。当我将示例 HttpSnoopClient ( https://github.com/netty/netty/blob/4.1/example/src/main/java/io/netty/example/http/snoop/HttpSnoopClient.java ) 连接到例如 Http2Server。

那么,这是 Netty 的问题吗?还是在 netty-tcnative-boringssl-static 中?还是在 http2.golang.org 中?还是在我的设置中?

我会很感激有关此事的任何线索。

标签: javanettyhttp2

解决方案


推荐阅读