0
votes

See I'm able to enable HTTP/2 support at user interface on jetty server with JDK8 by excluding tomcat starter and adding jetty started to spring web config and also added jetty-alpn-conscrypt-server, http2-server dependency.

But at the Spring Cloud API Gateway side that is using Netty server, I tried all the steps and unable to figure out, how to enable HTTP/2 here at Spring Cloud API Gateway, I've added netty-tcnative-boringssl-static as a dependency and now I'm getting this error

2020-11-24 23:34:18.957 ERROR 10732 --- [ctor-http-nio-2] reactor.netty.tcp.TcpServer : [id: 0xf9cd86ed, L:/127.0.0.1:9001 - R:/127.0.0.1:58801](H2 - 1) onUncaughtException(SimpleConnection{channel=[id: 0xf9cd86ed, L:/127.0.0.1:9001 - R:/127.0.0.1:58801](H2 - 1)})

2020-11-24 23:55:24.385 ERROR 19564 --- [ctor-http-nio-2] reactor.netty.tcp.TcpServer              : [id: 0xb5f89ffb, L:/127.0.0.1:9001 - R:/127.0.0.1:58977](H2 - 1) onUncaughtException(SimpleConnection{channel=[id: 0xb5f89ffb, L:/127.0.0.1:9001 - R:/127.0.0.1:58977](H2 - 1)})

java.lang.ClassCastException: io.netty.handler.codec.http2.Http2MultiplexCodec$Http2MultiplexCodecStreamChannel cannot be cast to io.netty.channel.socket.SocketChannel
    at reactor.netty.http.server.Http2StreamBridgeHandler.channelRead(Http2StreamBridgeHandler.java:77) ~[reactor-netty-0.8.12.RELEASE.jar:0.8.12.RELEASE]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.AbstractHttp2StreamChannel$Http2ChannelUnsafe.doRead0(AbstractHttp2StreamChannel.java:851) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.AbstractHttp2StreamChannel.fireChildRead(AbstractHttp2StreamChannel.java:533) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2MultiplexCodec.onHttp2Frame(Http2MultiplexCodec.java:142) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.onHeadersRead(Http2FrameCodec.java:569) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2FrameCodec$FrameListener.onHeadersRead(Http2FrameCodec.java:563) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2FrameListenerDecorator.onHeadersRead(Http2FrameListenerDecorator.java:48) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2EmptyDataFrameListener.onHeadersRead(Http2EmptyDataFrameListener.java:63) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onHeadersRead(DefaultHttp2ConnectionDecoder.java:373) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader$1.processFragment(DefaultHttp2FrameReader.java:457) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readHeadersFrame(DefaultHttp2FrameReader.java:464) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:254) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:174) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.DecoratingHttp2ConnectionDecoder.decodeFrame(DecoratingHttp2ConnectionDecoder.java:63) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:505) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:444) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:283) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.http2.Http2MultiplexCodec.channelRead(Http2MultiplexCodec.java:267) [netty-codec-http2-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1347) [netty-handler-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1236) [netty-handler-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1273) [netty-handler-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:505) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:444) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:283) [netty-codec-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1421) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511) [netty-transport-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918) [netty-common-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.39.Final.jar:4.1.39.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.39.Final.jar:4.1.39.Final]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_181]
 

Spring Boot: 2.1.9.RELEASE Spring Cloud: Greenwich.SR3 Java Version: JDK-8

1
You have an issue fixed an year ago github.com/reactor/reactor-netty/issues/864Violeta Georgieva
already checked this and similar links but nothing is working for me I'm on Spring Boot: 2.1.9.RELEASE Spring Cloud: Greenwich.SR3 Java Version: JDK-8Vinod
Did you try the fixed Reactor Netty version which is > 0.8.12.RELEASE, because in the stack trace above you still use the version where the problem exists?Violeta Georgieva
yes then it started giving different dependencies errorsVinod

1 Answers

0
votes

I fixed this issue by upgrading boot version to 2.2.5.RELEASE and cloud version to Hoxton.SR3