INFO,io.grpc.netty.shaded.io.grpc.netty.NettyServerTransport.connections,199,…
- User
INFO,io.grpc.netty.shaded.io.grpc.netty.NettyServerTransport.connections,199, io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 70696e67| at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.connectionError(Http2Exception.java:103),Transport failed, io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception: HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 70696e67| at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.connectionError(Http2Exception.java:103)| at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandlerPrefaceDecoder.decode(Http2ConnectionHandler.java:239)| at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438)| at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:498)| at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:437)| at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)| at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)| at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)| at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)| at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipelineEpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:792)| at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:475)| at io.grpc.netty.shaded.io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)| at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor2.run(ThreadExecutorMap.java:74)| at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)| at java.base/java.lang.Thread.run(Thread.java:829)
- Assistant
This error message is related to the io.grpc.netty.shaded.io.netty.handler.codec.http2 package in the gRPC library. The error indicates that the HTTP/2 client preface string is missing or corrupt.
The HTTP/2 client preface string is a specific sequence of bytes that is exchanged between the client and server to establish a connection. In this case, the received bytes do not match the expected preface string, resulting in the HTTP2Exception.
It's likely that there is an issue with the client or server configuration, or there may be a problem with the network connection. To troubleshoot the issue, you can check the client and server configurations, ensure that the network connection is stable, and verify that the expected preface string is being exchanged correctly.
You may also want to consult the gRPC documentation or seek support from the gRPC community for further assistance in resolving this issue.
- User
gcp function 连接java 程序报错 HTTP/2 client preface string missing or corrupt. Hex dump for received bytes
- Assistant
当连接GCP函数(Google Cloud Platform Functions)和Java程序时,出现"HTTP/2 client preface string missing or corrupt. Hex dump for received bytes"的错误消息,通常是因为gRPC使用的HTTP/2协议在建立连接时遇到问题。
可能有以下几种原因导致该错误:
-
版本不匹配:确保 gRPC 与相关依赖的版本兼容。请检查 gRPC、Netty 和 HTTP/2 相关库的版本,确保它们能够协同工作。
-
网络代理问题:某些网络代理可能会干扰或修改 HTTP/2 的连接请求,导致服务端无法正确解析客户端的 preface string。尝试绕过代理或配置代理以适应 HTTP/2 协议。
-
TLS/SSL 问题:如果您的Java程序使用了自定义的TLS/SSL配置,请确保配置正确且与gRPC预期的请求进行了正确的匹配。例如,检查是否使用了正确的证书和密钥。
-
应用程序逻辑错误:检查Java程序中关于gRPC连接的代码逻辑,确保正确使用gRPC的API进行连接,没有手动修改或篡改请求。
针对这些情况,您可以尝试以下解决方案:
- 确认 gRPC 相关库的版本兼容性,并根据需要进行升级。
- 检查网络代理配置,尝试绕过代理或调整代理设置以适应HTTP/2协议。
- 检查TLS/SSL配置,确保它们与gRPC预期的请求进行匹配。
- 检查和调试Java程序的连接逻辑,确保没有手动修改或篡改请求。
如果以上解决方案都无法解决问题,建议参考gRPC和GCP函数的文档或寻求相关社区的支持来获取更深入的帮助和指导。
-