[Question] Why does my netty is unresponsible after two blocked request?
See original GitHub issueExpected behavior
I expect I/O Threads to keep consuming requests.
Actual behavior
After 2 blocked requests. It starts to not accepting requests. Even If I am using 16 Threads as a child worker Thread
Steps to reproduce
1-) Send open the websocket request 2-) On the Server side block the in the coming event before handshake for 20 Secs (In My real case, It is a blocked JDBC call before the handshake. I need to validate the incoming request with querying DB before opening the socket) 3-) Do It above Steps two times 4-) For requests after 3, the server starts to not answering until the first blocking request done.
Minimal yet complete reproducer code (or URL to code)
@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, HttpRequest httpRequest) {
Thread.sleep(20000); // Represents my blocked logic before handshake
// Handsake or not with result
Do stuff...
}
EventLoopGroup bossGroup = new NioEventLoopGroup(1);
EventLoopGroup workerGroup = new NioEventLoopGroup();
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(HTTP_CODEC.value(), new HttpServerCodec());
.
.
.
Netty version
4.1.59.Final
JVM version (e.g. java -version
)
1.8 don’t be mad at me 😛
I am passing blocked business logic to the custom thread pool. But, In the handshake case, I can not do that. and After two blocked requests my netty server is unresponsible until the first one ends. Is there any good way to handle the blocked handshake logic without block child threads.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
Aaaaaaaaaaaaa, I gotcha. You’re using ‘SimpleChannelInboundHandler’. It’ll release Http Request as soon as it finishes processing channelRead0. (Even before your logic finishes in 500ms).
Use ChannelInboundHandler.
Thanks for the help @hyperxpro It was about to retain/release the message as you said. Very thanks for the answer to my question