Pipeline configuration: Decoder, Handler, Encoder - throws: UnsupportedOperationException: unsupported message type: DefaultHttpResponse (expected: ByteBuf, FileRegion)
See original GitHub issueExpected behavior
The pipeline configuration:
- Decoder
- Handler
- Encoder should not throw exception when a client sends HTTP request.

By reading the documentation, the order should be executed like so:
Inbound: Decoder, Handler
Outbound: Encoder
Actual behavior
The pipeline thorws exception:
Aug 14, 2022 2:14:04 PM io.netty.channel.DefaultChannelPipeline onUnhandledInboundException
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.UnsupportedOperationException: unsupported message type: DefaultHttpResponse (expected: ByteBuf, FileRegion)
Steps to reproduce
- Clone my repo: https://github.com/ShlomiRex/netty-pipeline-test
- Run the code with the pipeline configuration:

- Send dummy HTTP request:
curl -v 127.0.0.1:8080 - The program throws exception.
- Uncomment the ‘Works’ section, and comment the ‘Doesn’t work’ section and see that it works, but not the other way around.
Minimal yet complete reproducer code (or URL to code)
https://github.com/ShlomiRex/netty-pipeline-test
Netty version
4.1.10.Final
JVM version (e.g. java -version)
11
OS version (e.g. uname -a)
- macOS 12.6, macbook pro 16 M1
- Linux CentOS
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Unable to write DefaultHttpResponse to a channel in netty ...
Unable to write DefaultHttpResponse to a channel in netty: "unsupported message type: class org.jboss.netty.handler.codec.http.
Read more >Index (Netty API Reference (4.0.56.Final))
Returns true if and only if the specified message can be decoded by this codec. acceptInboundMessage(Object) - Method in class io.netty.handler.codec.
Read more >Java Examples for io.netty.channel.ChannelHandler
Add a handler to pipeline if it is not already added * and configure the ... void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception ......
Read more >Netty in Action MEAP v05
A ByteBuffer is fundamental to both NIO APIs and, indeed, to Netty. ... There are various types of base classes for encoders and...
Read more >Netty in Action v9 MEAP PDF | Thread (Computing) | Net Beans
6 ChannelHandler and ChannelPipeline 7 The Codec framework 8 Provided ChannelHandlers and Codecs 9 Bootstrapping Netty Applications PART 3: NETTY BY EXAMPLE
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If your handler does a write to the
ChannelHandlerContextit’s passed in, say,channelRead, then the write will propagate up from the handlers position in the pipeline. Otherwise handlers wouldn’t have a way to pass the write through.If you do a write to the
Channel, then it’ll propagate from the bottom of the pipeline.Thanks a lot! If I change
ctx.write()toctx.channel.write()it propogates to the next pipeline as expected! And so the code:works! (it didn’t work before because I was writing to context, and not channel).
Your a life savior!