spring-cloud-gateway: Cannot route to https URI: unexpected message type
Using GW M8 the following exception occurs when the GW tries to route to a URI over https.
io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: DefaultHttpRequest
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106) ~[netty-codec-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:348) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:291) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1051) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at reactor.ipc.netty.http.HttpOperations.lambda$then$0(HttpOperations.java:135) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.ipc.netty.FutureMono.lambda$deferFuture$0(FutureMono.java:68) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.ipc.netty.FutureMono$DeferredFutureMono.subscribe(FutureMono.java:134) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.core.publisher.Mono.subscribe(Mono.java:3080) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:167) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.core.publisher.Mono.subscribe(Mono.java:3080) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.ipc.netty.NettyOutbound.subscribe(NettyOutbound.java:356) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.core.publisher.MonoSource.subscribe(MonoSource.java:51) ~[reactor-core-3.1.5.RELEASE.jar:3.1.5.RELEASE]
at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:380) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at reactor.ipc.netty.http.client.HttpClientOperations.onHandlerStart(HttpClientOperations.java:501) ~[reactor-netty-0.7.5.RELEASE.jar:0.7.5.RELEASE]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) ~[netty-transport-4.1.22.Final.jar:4.1.22.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) ~[netty-common-4.1.22.Final.jar:4.1.22.Final]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_144]
I will create a github repo with a sample to recreate the problem.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 68 (35 by maintainers)
@tony-clarke-amdocs Is your problem solved? I encountered the same problem in stress testing.
The reactor team is looking at things
@spencergibb @violetagg Hi, we are still seeing this problem with Spring Cloud Gateway 2.0.2 which uses reactor-netty 0.7.10.RELEASE. In order to reproduce the problem you need to run for a long time. In an 8 hour run it occurs one time. The latest stack trace looks like:
Thank you for the update. I’ve kicked off a test run using reactor-netty-0.7.8.BUILD-20180606.174842-17.jar
I think this one should fix the issue https://github.com/reactor/reactor-netty/pull/371 let us review it a bit and then we will commit it to the 0.7.x snapshot
Not seeing issues so far with this (abbreviated)
build.gradle@bcelenk thanks for the detailed explanation! @spencergibb @tony-clarke-amdocs I’m experiencing this exact problem as well, is there a way to try out
0.8.0.M1of thereactor-nettywith this? When I try to use it withspring-boot-dependenciesof version2.1.0.M1, I can get thereactor-nettyon board with version:0.8.0.M1butreactor.ipc.netty.http.server.HttpServerOptionsclass is missing with that so my code doesn’t compile?Hi,
I’ve come across with the same problem, reproducing is trivial. Below is the stack trace.
I’m using raw cloud-gateway and webflux which are both produced by Spring Initializr/no modifications, just added a uuid to represent each user’s session.
Load is generated using Gatling, 2000rps. Below is the gatling’s scala file.
After 11k requests, exception occurred. This number varies between tests.
Gateway/reactor-netty’s context when exception is occurred:
Origin is unaware about exception
Wireshark HTTP packages, user’s first two request were delegated to origin, 3rd one wasn’t forwarded.
Last http package’s details
Tcp stream of the last http package(produces using right-click>follow TCP stream):
All apps are run on my personal macbook, same exception also occurs on EC2/Linux per gateway/origin with genuine clients.
Macbook specs: macOS High Sierra 10.13.6 (17G65) Processor 2.2 GHz Intel Core i7 Memory 16 GB 1600 MHz DDR3 Tried with 3 different jdks: jdk1.8.0_131 jdk1.8.0_171 jdk1.8.0_181
@violetagg @spencergibb Using netty-reactor 0.7.8 is much better, but it is not 100% fixed. Now I see an exception
javax.net.ssl.SSLException: SSLEngine closed already at io.netty.handler.ssl.SslHandler.wrap(...)(Unknown Source)~[netty-handler-4.1.25.Final.jar!/:4.1.25.Final]This exception occurs maybe 10 times in a 5 hour test. You can use this repo to reproduce the problem.Disabling the netty client pool solves the problems for any recent version of the spring cloud gateway.
I’ve been assuming this problem was originally related to https, but maybe that’s not true anymore. I’ll change my test to use http and see what happens.
@spencergibb is this potentially a release blocker?
@spencergibb any update from the reactor team/issue to track on their end? Running into the same issue intermittently.