You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by "minchengbo (Jira)" <ji...@apache.org> on 2020/05/12 01:58:00 UTC

[jira] [Created] (PLC4X-197) Static Timer stopped issue when multiple tcpconnections

minchengbo created PLC4X-197:
--------------------------------

             Summary: Static Timer stopped issue when multiple tcpconnections
                 Key: PLC4X-197
                 URL: https://issues.apache.org/jira/browse/PLC4X-197
             Project: Apache PLC4X
          Issue Type: Bug
          Components: Driver-Modbus
    Affects Versions: 0.6.0
            Reporter: minchengbo
         Attachments: testcase.java

NettyPlcConnection creates a staitc timer,  this timer may be closed in SingleItemToSingleRequestProtocol, and then the other NettyPlcConnection will get ExecutionException:
Caused by: java.lang.IllegalStateException: cannot be started once stoppedCaused by: java.lang.IllegalStateException: cannot be started once stopped at io.netty.util.HashedWheelTimer.start(HashedWheelTimer.java:350) at io.netty.util.HashedWheelTimer.newTimeout(HashedWheelTimer.java:429) at org.apache.plc4x.java.base.protocol.SingleItemToSingleRequestProtocol.write(SingleItemToSingleRequestProtocol.java:288)





/////////////////NettyPlcConnection.java

public abstract class NettyPlcConnection extends AbstractPlcConnection {

/**
 * a \{@link HashedWheelTimer} shall be only instantiated once.
 */
 // TODO: maybe find a way to make this configurable per jvm
 protected final static Timer timer = new HashedWheelTimer();

protected final ChannelFactory channelFactory;




/////////////////////////////////   SingleItemToSingleRequestProtocol.java
 @Override
 public void channelInactive(ChannelHandlerContext ctx) throws Exception {
 // Send everything so we get a proper failure for those pending writes
 this.queue.removeAndWriteAll();
 this.timer.stop();
 this.scheduledTimeouts.clear();
 this.sentButUnacknowledgedSubContainer.clear();
 this.correlationToParentContainer.clear();
 this.containerCorrelationIdMap.clear();
 this.responsesToBeDelivered.clear();
 this.correlationIdGenerator.set(0);
 this.deliveredItems.set(0);
 this.erroredItems.set(0);
 this.deliveredContainers.set(0);
 this.erroredContainers.set(0);
 super.channelInactive(ctx);
 }



--
This message was sent by Atlassian Jira
(v8.3.4#803005)