[
https://issues.apache.org/jira/browse/PLC4X-197?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17105614#comment-17105614
]
César García commented on PLC4X-197:
------------------------------------
Hello,
Do not close the connection until you finish all operations.
If you run multiple instances of the driver, you will necessarily have to
ensure that the last one to finish closes the connection.
In my case to run multiple instances of the driver comment the section "//
this.timer.stop ();".
I don't know if this is a solution applicable to this case.
As Chris comments, it is best to go to version 0.7.0-SNAPSHOP.
Best regards,
> tcp connection issue: Static Timer stopped when multiple tcpconnections
> -----------------------------------------------------------------------
>
> Key: PLC4X-197
> URL: https://issues.apache.org/jira/browse/PLC4X-197
> Project: Apache PLC4X
> Issue Type: Bug
> Components: Core, Driver-Modbus
> Affects Versions: 0.6.0
> Reporter: minchengbo
> Priority: Critical
> 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)