Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,9 @@ private PlcResponseCode decodeResponseCode(short status) {
return PlcResponseCode.NOT_FOUND;
}

@Override
public void channelInactive(ConversationContext<CIPEncapsulationPacket> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1984,4 +1984,9 @@ protected byte[] getNullByteTerminatedArray(String value) {
return nullTerminatedBytes;
}

@Override
public void channelInactive(ConversationContext<AmsTCPPacket> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,9 @@ private String toString(BacNetIpTag tag) {
return tag.getDeviceIdentifier() + "/" + tag.getObjectType() + "/" + tag.getObjectInstance();
}

@Override
public void channelInactive(ConversationContext<BVLC> context) {
// Nothing to do here ...
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public CompletableFuture<PlcReadResponse> read(PlcReadRequest readRequest) {
protected void decode(ConversationContext<CBusCommand> context, CBusCommand msg) throws Exception {
}

@Override
public void channelInactive(ConversationContext<CBusCommand> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,9 @@ public void close(ConversationContext<C> context) {
delegate.close(new ConversationContextWrapper<>(context, wireType, adapter, frameHandler, context.getAuthentication()));
}

@Override
public void channelInactive(ConversationContext<C> context) {
delegate.close(new ConversationContextWrapper<>(context, wireType, adapter, frameHandler, context.getAuthentication()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,9 @@ public PlcConsumerRegistration register(Consumer<PlcSubscriptionEvent> consumer,
public void unregister(PlcConsumerRegistration registration) {
consumers.remove(registration);
}

@Override
public void channelInactive(ConversationContext<GenericFrame> context) {
tm.shutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,9 @@ public void onDisconnect(ConversationContext<CANOpenFrame> context) {
}
}

@Override
public void channelInactive(ConversationContext<CANOpenFrame> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1355,4 +1355,9 @@ private PlcResponseCode decodeResponseCode(int status) {
}
}

@Override
public void channelInactive(ConversationContext<EipPacket> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,9 @@ protected BitSet getDigitalValues(int byteBlock, List<Byte> data) {
return BitSet.valueOf(bitSetData);
}

@Override
public void channelInactive(ConversationContext<FirmataMessage> context) {
connected.set(false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,9 @@ protected void publishEvent(LocalDateTime timeStamp, Iec608705104Tag tag, PlcVal
}
}

@Override
public void channelInactive(ConversationContext<APDU> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -640,4 +640,9 @@ protected static String toString(KnxGroupAddress groupAddress) {
throw new PlcRuntimeException("Unsupported Group Address Type " + groupAddress.getClass().getName());
}

@Override
public void channelInactive(ConversationContext<KnxNetIpMessage> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public void close(ConversationContext<T> context) {
// Nothing to do here ...
}

@Override
public void channelInactive(ConversationContext<T> context) {
// Nothing to do here ...
}

@Override
protected void decode(ConversationContext<T> context, T msg) throws Exception {
super.decode(context, msg);
Expand Down Expand Up @@ -417,5 +422,4 @@ public static byte[] byteSwap(byte[] in) {
}
return out;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public void close(ConversationContext<ModbusTcpADU> context) {
tm.shutdown();
}

@Override
public void channelInactive(ConversationContext<ModbusTcpADU> context) {
tm.shutdown();
}

@Override
public CompletableFuture<PlcPingResponse> ping(PlcPingRequest pingRequest) {
CompletableFuture<PlcPingResponse> future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,4 +901,8 @@ private static <T> void bridge(RequestTransaction transaction, CompletableFuture
}
}

@Override
public void channelInactive(ConversationContext<OpcuaAPU> context) {
tm.shutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,8 @@ public PlcConsumerRegistration register(Consumer<PlcSubscriptionEvent> consumer,
public void unregister(PlcConsumerRegistration plcConsumerRegistration) {
}

@Override
public void channelInactive(ConversationContext<OpenProtocolMessage> context) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,9 @@ protected void decode(ConversationContext<Plc4xMessage> context, Plc4xMessage ms
super.decode(context, msg);
}

@Override
public void channelInactive(ConversationContext<Plc4xMessage> context) {
tm.shutdown();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -905,4 +905,9 @@ protected int getDataTypeLengthInBytes(PlcValueType dataType) {
throw new PlcRuntimeException("Length undefined");
}

@Override
public void channelInactive(ConversationContext<Ethernet_Frame> context) {
context.getChannel().close();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,9 @@ public CompletableFuture<PlcSubscriptionResponse> subscribe(PlcSubscriptionReque
protected void decode(ConversationContext<Ethernet_Frame> context, Ethernet_Frame msg) throws Exception {
super.decode(context, msg);
}

@Override
public void channelInactive(ConversationContext<Ethernet_Frame> context) {
// TODO:- Do something here
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2494,4 +2494,8 @@ public int getCurLength() {

}

}
@Override
public void channelInactive(ConversationContext<TPKTPacket> context) {
tm.shutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public void close(ConversationContext<TPKTPacket> context) {
tm.shutdown();
}

@Override
public void channelInactive(ConversationContext<TPKTPacket> context) {
tm.shutdown();
}

@Override
public void onConnect(ConversationContext<TPKTPacket> context) {
// Only the TCP transport supports login.
Expand Down Expand Up @@ -1099,5 +1104,4 @@ public int getCurLength() {
}

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,19 @@ public ExpectRequestContext<T> expectRequest(Class<T> clazz, Duration timeout) {

@Override
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
logger.trace("close.. context: {}", ctx.name());
super.close(ctx, promise);
timeoutManager.stop();
}

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
logger.trace("channelInactive.. context: {}", ctx.name());
super.channelInactive(ctx);
this.protocolBase.channelInactive(new DefaultConversationContext<>(this::registerHandler, ctx, authentication, passive));
timeoutManager.stop();
}

@Override
protected void encode(ChannelHandlerContext channelHandlerContext, Object msg, List<Object> list) throws Exception {
logger.debug("Forwarding request to plc {}", msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ public CompletableFuture<PlcBrowseResponse> browseWithInterceptor(PlcBrowseReque

public abstract void close(ConversationContext<T> context);

public abstract void channelInactive(ConversationContext<T> context);

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ class DefaultNettyPlcConnectionTest {
final GateKeeper connect = new GateKeeper("connect");
final GateKeeper disconnect = new GateKeeper("disconnect");
final GateKeeper close = new GateKeeper("close");
final GateKeeper channelInactive = new GateKeeper("channelInactive");

@Test
void checkInitializationSequence() throws Exception {
ChannelFactory channelFactory = new TestChannelFactory();

ProtocolStackConfigurer<Message> stackConfigurer = (configuration, pipeline, authentication, passive, listeners) -> {
TestProtocolBase base = new TestProtocolBase(discovery, connect, disconnect, close);
TestProtocolBase base = new TestProtocolBase(discovery, connect, disconnect, close, channelInactive);
Plc4xNettyWrapper<Message> context = new Plc4xNettyWrapper<>(new NettyHashTimerTimeoutManager(), pipeline, passive, base, authentication, Message.class);
pipeline.addLast(context);
return base;
Expand Down Expand Up @@ -153,12 +154,14 @@ static class TestProtocolBase extends Plc4xProtocolBase<Message> {
private final GateKeeper connect;
private final GateKeeper close;
private final GateKeeper disconnect;
private final GateKeeper channelInactive;

public TestProtocolBase(GateKeeper discover, GateKeeper connect, GateKeeper disconnect, GateKeeper close) {
public TestProtocolBase(GateKeeper discover, GateKeeper connect, GateKeeper disconnect, GateKeeper close, GateKeeper channelInactive) {
this.discover = discover;
this.connect = connect;
this.close = close;
this.disconnect = disconnect;
this.channelInactive =channelInactive;
}

@Override
Expand Down Expand Up @@ -210,6 +213,13 @@ private void awaitIn(GateKeeper signal) {
throw new RuntimeException(e);
}
}
}

@Override
public void channelInactive(ConversationContext<Message> context) {
logger.info("On ChannelInactive");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set this to "debug" or "trace"

channelInactive.permitEntry();
awaitIn(channelInactive);
channelInactive.reportExit();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public void close(ConversationContext<TestMessage> context) {
context.getChannel().close();
}

@Override
public void channelInactive(ConversationContext<TestMessage> context) {
context.getChannel().close();
}

}