using reader idle to trigger the will message.

When client power off directly, the socket is broken and server may
still push messages, which just occurred TCP re-transmission at that
time, instead of raising an error immediately. This delayed the will
message.
This commit is contained in:
fjcyue
2017-03-12 01:03:13 +08:00
parent 46d27e3bea
commit 96fb6301a8
4 changed files with 8 additions and 8 deletions
@@ -33,7 +33,7 @@ class MoquetteIdleTimeoutHandler extends ChannelDuplexHandler {
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt instanceof IdleStateEvent) {
IdleState e = ((IdleStateEvent) evt).state();
if (e == IdleState.ALL_IDLE) {
if (e == IdleState.READER_IDLE) {
LOG.info("Firing channel inactive event. MqttClientId = {}.", NettyUtils.clientID(ctx.channel()));
// fire a channelInactive to trigger publish of Will
ctx.fireChannelInactive();