Netty write several messages through one channel

2019-08-15 06:39发布

问题:

I'm newbie in Netty. I want send several messages through one channel in this way

channel.writeAndFlush(Unpooled.copiedBuffer("TBD", CharsetUtil.UTF_8)).sync()
channel.writeAndFlush(Unpooled.copiedBuffer("TBD1", CharsetUtil.UTF_8)).sync()

But this code produce java.nio.channels.ClosedChannelException. How to do it correctly?

回答1:

This means the Channel was closed before. You should investigate the cause for this.