Does Netty always close channel if unable to send a message

时间:2016-08-31 18:13:34

标签: java connection netty

I am using Netty 4.1. Let's say I have an active netty channel (TCP or SSL) and I write a message to it. The message goes through all of my handlers without a problem. If netty is unable to send this message for any reason, am I guaranteed that the channel will be closed (and close future listener invoked)?

I am trying to see if I can avoid registering a listener for every write and use the voidPromise() optimization:

nettyChannel.writeAndFlush(message, nettyChannel.voidPromise());

1 个答案:

答案 0 :(得分:2)

No it will not. That said if an IOException is thrown from the Socket it will close the Channel.