Skip to content

Commit

Permalink
Override IdleTimeout to fix Error
Browse files Browse the repository at this point in the history
  • Loading branch information
dushibaiyu committed Jun 15, 2018
1 parent d5fecba commit 77e412c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/io/vertx/mqtt/MqttServerOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,12 @@ public MqttServerOptions setTimeoutOnConnect(int timeoutOnConnect) {
public int timeoutOnConnect() {
return this.timeoutOnConnect;
}

/**
* @return the TCP idle timeout, in seconds,In Mqtt Server the Parameter will be invaild, it will use timeoutOnConnect.
*/
@Override
public int getIdleTimeout() {
return 0;
}
}
3 changes: 2 additions & 1 deletion src/main/java/io/vertx/mqtt/impl/MqttServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private void initChannel(ChannelPipeline pipeline) {
}

// adding the idle state handler for timeout on CONNECT packet
pipeline.addBefore("handler", "mqttIdle", new IdleStateHandler(this.options.timeoutOnConnect(), 0, 0));
pipeline.addBefore("handler", "idle", new IdleStateHandler(this.options.timeoutOnConnect(), 0, 0));
pipeline.addBefore("handler", "timeoutOnConnect", new ChannelDuplexHandler() {

@Override
Expand All @@ -154,5 +154,6 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
}
}
});

}
}

0 comments on commit 77e412c

Please sign in to comment.