ClosedChannelException
FreedomAlanLiu opened this issue · comments
Alan Liu commented
An 'ClosedChannelException' occurred while writing, but the 'stateContext' has not changed.
ModbusTcpMaster.java:
ch.writeAndFlush(new ModbusTcpPayload(txId, (short) unitId, request)).addListener(f -> {
if (!f.isSuccess()) {
// How to fix? Whether we can?
/*Throwable cause = f.cause();
if (f.cause() instanceof ClosedChannelException) {
stateContext.handleEvent(ConnectionEvent.ChannelClosed);
cause = new RuntimeException("Channel closed!", f.cause());
}*/
PendingRequest<?> p = pendingRequests.remove(txId);
if (p != null) {
p.promise.completeExceptionally(f.cause());
p.timeout.cancel();
}
}
});
Kevin Herron commented
I've been meaning to replace the FSM with a pattern I've used successfully in other libraries and I'm pretty sure it takes care of this issue. Check out the replace-fsm branch which has the current implementation.
Kevin Herron commented
1.1.0 is released