Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected message type: io.netty.handler.codec.http.DefaultHttpContent (expected: HttpResponse) #292

Closed
spencergibb opened this issue Feb 22, 2018 · 10 comments
Labels
type/bug A general bug
Milestone

Comments

@spencergibb
Copy link

Expected behavior

Not throw the error. (This worked with spring boot RC1)

Actual behavior

2018-02-22 13:26:50.584 ERROR 24141 --- [ctor-http-nio-6] r.ipc.netty.channel.ChannelOperations    : [HttpServer] Error processing connection. Requesting close the channel

io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: io.netty.handler.codec.http.DefaultHttpContent (expected: HttpResponse)
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:106) ~[netty-codec-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[netty-codec-4.1.21.Final.jar:4.1.21.Final]
	at reactor.ipc.netty.http.server.FilteringHttpContentCompressor.write(FilteringHttpContentCompressor.java:47) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at reactor.ipc.netty.http.server.CompressionHandler.writeCompress(CompressionHandler.java:125) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.http.server.CompressionHandler.drain(CompressionHandler.java:114) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.http.server.CompressionHandler.offerByteBuf(CompressionHandler.java:106) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.http.server.CompressionHandler.write(CompressionHandler.java:48) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at reactor.ipc.netty.http.server.HttpServerHandler.write(HttpServerHandler.java:212) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:316) [reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler$PublisherSender.onNextInternal(ChannelOperationsHandler.java:638) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler$PublisherSender.onNext(ChannelOperationsHandler.java:622) ~[reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:108) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onNext(FluxConcatArray.java:169) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:1626) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:1440) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:1314) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.Mono.subscribe(Mono.java:3077) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onComplete(FluxConcatArray.java:200) ~[reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.FluxConcatArray.subscribe(FluxConcatArray.java:80) [reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.FluxMap.subscribe(FluxMap.java:62) [reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.core.publisher.Flux.subscribe(Flux.java:6869) [reactor-core-3.1.4.RELEASE.jar:3.1.4.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:461) [reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191) [reactor-netty-0.7.4.RELEASE.jar:0.7.4.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext.access$1500(AbstractChannelHandlerContext.java:38) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:1129) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:1070) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) [netty-transport-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) [netty-common-4.1.21.Final.jar:4.1.21.Final]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_152]
Caused by: java.lang.IllegalStateException: unexpected message type: io.netty.handler.codec.http.DefaultHttpContent (expected: HttpResponse)
	at io.netty.handler.codec.http.HttpContentEncoder.ensureHeaders(HttpContentEncoder.java:240) ~[netty-codec-http-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.handler.codec.http.HttpContentEncoder.encode(HttpContentEncoder.java:96) ~[netty-codec-http-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.handler.codec.http.HttpContentEncoder.encode(HttpContentEncoder.java:51) ~[netty-codec-http-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.handler.codec.MessageToMessageCodec$1.encode(MessageToMessageCodec.java:67) ~[netty-codec-4.1.21.Final.jar:4.1.21.Final]
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88) ~[netty-codec-4.1.21.Final.jar:4.1.21.Final]
	... 45 common frames omitted

Steps to reproduce

https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixWebfluxEndpointTests.java

https://jenkins.spring.io/view/Spring%20Cloud/view/CI/job/spring-cloud-netflix-master-ci/5244/console

just remove @Ignore

Shared Flux created here https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixWebfluxEndpoint.java

Using this Publisher https://github.com/spring-cloud/spring-cloud-netflix/blob/1080a1dc8305c9a044d6a86be21eeeaabd02c4da/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/hystrix/HystrixAutoConfiguration.java#L97-L100

Reactor Core version

reactor-core-3.1.4.RELEASE.

JVM version (e.g. java -version)

8u152-zulu

@violetagg
Copy link
Member

Did you have the ping functionality before when the test was running against spring boot RC1?

@spencergibb
Copy link
Author

Yes

@violetagg
Copy link
Member

violetagg commented Feb 22, 2018

when I run the test with spring boot RC1 it hangs
and it is expected because of this issue #282

@spencergibb
Copy link
Author

How did you run it with RC1?

@spencergibb
Copy link
Author

spencergibb commented Feb 22, 2018

I'd expect current snapshots to fail with RC1 since there are incompatibilities. If I checkout v2.0.0.M6 (which brings in boot 2 RC1) the test passes.

reactor-core-3.1.3.RELEASE
reactor-netty-0.7.3.RELEASE

@violetagg violetagg added this to the 0.7.5.RELEASE milestone Feb 23, 2018
violetagg added a commit that referenced this issue Feb 23, 2018
Reset compression threshold filter on handler terminated

Related to issue #292
@smaldini smaldini added the type/bug A general bug label Feb 26, 2018
smaldini pushed a commit that referenced this issue Feb 27, 2018
Previously the logic was not updating the buffer pending bytes.
Thus would prevent flush logic to operate correctly. Also
A convoluted FilteringCompressor was used.
smaldini pushed a commit that referenced this issue Feb 27, 2018
Previously the logic was not updating the buffer pending bytes.
Thus would prevent flush logic to operate correctly. Also
A convoluted FilteringCompressor was used.
@myhau
Copy link

myhau commented Feb 27, 2018

@violetagg Does your PR #294 resolve this issue ? Or is there any workaround or combination of versions of reactor-core, reactor-netty spring-boot that will solve this issue temporarily ?

@violetagg
Copy link
Member

We are still working on this. You can expect a solution later today.

@myhau
Copy link

myhau commented Feb 27, 2018

@violetagg @smaldini Maybe you are already aware of that, but this issue is also present when using HttpClient (through Spring's ReactorClientHttpConnector) with compression turned off.

Stack-trace:

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.20.Final.jar:4.1.20.Final]
	at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:348) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:816) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:723) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:291) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:191) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:831) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1049) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300) ~[netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at reactor.ipc.netty.http.HttpOperations.lambda$sendHeaders$0(HttpOperations.java:128) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at reactor.ipc.netty.FutureMono$DeferredFutureMono.subscribe(FutureMono.java:106) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at reactor.core.publisher.Mono.subscribe(Mono.java:3006) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
	at reactor.core.publisher.FluxConcatIterable$ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:141) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
	at reactor.core.publisher.FluxConcatIterable.subscribe(FluxConcatIterable.java:60) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
	at reactor.core.publisher.MonoSourceFlux.subscribe(MonoSourceFlux.java:47) ~[reactor-core-3.1.3.RELEASE.jar:3.1.3.RELEASE]
	at reactor.ipc.netty.channel.ChannelOperations.applyHandler(ChannelOperations.java:371) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at reactor.ipc.netty.http.client.HttpClientOperations.onHandlerStart(HttpClientOperations.java:479) ~[reactor-netty-0.7.3.RELEASE.jar:0.7.3.RELEASE]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163) [netty-common-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java) [netty-common-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-common-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) [netty-transport-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) [netty-common-4.1.20.Final.jar:4.1.20.Final]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_92]
Caused by: java.lang.IllegalStateException: unexpected message type: DefaultHttpRequest
	at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:86) ~[netty-codec-http-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:167) ~[netty-codec-http-4.1.20.Final.jar:4.1.20.Final]
	at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:88) ~[netty-codec-4.1.20.Final.jar:4.1.20.Final]
	... 29 more

Versions:

spring-boot 2.0.0.RC1
reactor-core 3.1.3.RELEASE
reactor-netty 0.7.3.RELEASE

Please let me know if you want some more info / code for reproducing it.

@violetagg
Copy link
Member

Any chance to provide some reproducible scenario?

@myhau
Copy link

myhau commented Feb 27, 2018

Yes, today I will share a repo with test

smaldini pushed a commit that referenced this issue Feb 27, 2018
Add HttpServerResponse#compression to control per response compression.
smaldini pushed a commit that referenced this issue Feb 27, 2018
Add HttpServerResponse#compression to control per response compression.
smaldini pushed a commit that referenced this issue Feb 27, 2018
Add HttpServerResponse#compression to control per response compression.
spencergibb added a commit to spring-cloud/spring-cloud-netflix that referenced this issue Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants