In Netty 4 "proxy" example, the channel auto read option has been disabled:
serverBootStrap.group(bossGroup, workerGroup)
...
.childOption(ChannelOption.AUTO_READ, false)
If commented childOption(ChannelOption.AUTO_READ, false)
, the proxy example will cannot work. And more detailed, in the method channelRead
of the class HexDumpProxyFrontendHandler
, the outboundChannel
will always be inactive.
And I have researched Netty source code, found that "auto read" will affect like that in methods fireChannelActive
and fireChannelReadComplete
of the class DefaultChannelPipeline
if (channel.config().isAutoRead()) {
read();
}
But I still cannot figure out what the relationship between auto read and the proxy example. In my mind, when a data send to the inbound buffer, Netty should fire the channel read event.
So there are two questions:
outboundChannel
always inactive?If you have not set autoread to false you may get into trouble if one channel writes a lot of data before the other can consume it. As it's all asynchronous you may end up with buffers that have too much data and hit OOME.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With