Uploaded image for project: 'Apache PLC4X'
  1. Apache PLC4X
  2. PLC4X-197

tcp connection issue: Static Timer stopped when multiple tcpconnections

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 0.6.0
    • 0.7.0
    • Core, Driver-Modbus
    • None

    Description

      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); }

      Attachments

        1. testcase.java
          3 kB
          minchengbo

        Activity

          People

            otto Otto Fowler
            minchengbo minchengbo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: