HTTP/2: changing `Http2StreamChannelConfig#setAutoRead()` from a different thread can stall or truncate a stream
Author: eager-signalCreated Sep 22, 2026Updated Sep 24, 2026
We have a server that proxies between two Http2Streams. It uses writability changes and auto-read to do some flow control:
peerStream.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelWritabilityChanged(final ChannelHandlerContext peerCtx) throws Exception {
otherStreamCtx.channel().config().setAutoRead(peerStream.isWritable());
super.channelWritabilityChanged(peerCtx);
}
});However, when a response body is >64 KiB (the initial flow-control window), and the streams don’t share an event loop, we experience stream stalls at 65535 bytes and truncations. We can work around it by ensuring we are on the same event loop:
if (!channel.eventLoop().inEventLoop()) {
channel.eventLoop().execute(() -> setAutoRead(channel, autoRead));
return;
}
channel.config().setAutoRead(autoRead);but should this be done within Http2StreamChannelConfig? I see similar logic for Http2StreamChannelOption.AUTO_STREAM_FLOW_CONTROL.
Source: netty/netty