[
https://issues.apache.org/jira/browse/PLC4X-326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17450166#comment-17450166
]
DHANABALAN DURAIRAJASIVAM commented on PLC4X-326:
-------------------------------------------------
Hi Chris,
Thanks for your response.
I have been trying pooled connection after your suggestion, but after few scan
it is throwing exceptions like shown here.
2021-11-29 10:13:28.767 INFO LAPTOP --- [/producer-route]
o.a.p.j.PlcDriverManager : Instantiating new PLC Driver Manager
with class loader
org.springframework.boot.devtools.restart.classloader.RestartClassLoader@84b73e5
2021-11-29 10:13:28.768 INFO LAPTOP --- [/producer-route]
o.a.p.j.PlcDriverManager : Registering available drivers...
2021-11-29 10:13:28.768 INFO LAPTOP --- [/producer-route]
o.a.p.j.PlcDriverManager : Registering driver for Protocol
modbus (Modbus)
2021-11-29 10:13:28.768 INFO LAPTO --- [/producer-route]
o.a.p.j.u.c.CachedDriverManager : Creating new cached Connection for
url modbus:tcp://1xx.1xx.xx.xx?unit-identifier=255 with timeout 1000 ms
2021-11-29 10:13:28.784 INFO LAPTOP --- [onPool-worker-2]
o.a.p.j.t.t.TcpChannelFactory : Configuring Bootstrap with
Configuration{}
2021-11-29 10:13:33.802 WARN LAPTOP --- [ool-25-thread-1]
o.a.p.j.u.c.CachedDriverManager : Watchdog detected a long borrowed
connection, will be forcefully closed!
2021-11-29 10:13:33.802 WARN LAPTOP --- [onPool-worker-2]
o.a.p.j.u.c.CachedPlcConnection : Request finished with exception.
Reporting Connection as Broken
java.util.concurrent.CancellationException
at
java.base/java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2478)
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.lambda$wrapWithTimeout$0(CachedPlcConnection.java:84)
at
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at
java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
2021-11-29 10:13:33.802 WARN LAPTOP--- [onPool-worker-1]
o.a.p.j.u.c.CachedPlcConnection : Request finished with exception.
Reporting Connection as Broken
java.util.concurrent.CancellationException
at
java.base/java.util.concurrent.CompletableFuture.cancel(CompletableFuture.java:2478)
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.lambda$wrapWithTimeout$0(CachedPlcConnection.java:84)
at
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at
java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
2021-11-29 10:13:33.803 WARN LAPTOP---- [onPool-worker-1]
o.a.p.j.u.c.CachedDriverManager : Broken Connection was returned,
although it is not borrowed, currently.
2021-11-29 10:13:33.803 WARN LAPTOP---- [onPool-worker-2]
o.a.p.j.u.c.CachedDriverManager : Broken Connection was returned,
although it is not borrowed, currently.
2021-11-29 10:13:33.803 ERROR LAPTOP---- [/producer-route] c.j.e.b.ModbusScan
: Interrupted Exception fired
java.util.concurrent.ExecutionException:
org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Unable to finish
Request!
at
java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
at
java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2096)
at com.jtc.evcharger.bean.ModbusScan.GetEvChargerData(ModbusScan.java:197)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at
org.apache.camel.support.ObjectHelper.invokeMethodSafe(ObjectHelper.java:382)
at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:494)
at
org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:316)
at org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:286)
at
org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:146)
at
org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:81)
at
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:463)
at
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:179)
at
org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:184)
at
org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210)
at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)
at java.base/java.util.TimerThread.mainLoop(Timer.java:566)
at java.base/java.util.TimerThread.run(Timer.java:516)
Caused by: org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Unable to
finish Request!
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.closeConnectionExceptionally(CachedPlcConnection.java:146)
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection.access$100(CachedPlcConnection.java:47)
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection$2.apply(CachedPlcConnection.java:127)
at
org.apache.plc4x.java.utils.connectionpool2.CachedPlcConnection$2.apply(CachedPlcConnection.java:121)
at
java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
at
java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:911)
at
java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:483)
at
java.base/java.util.concurrent.ForkJoinTask.doExec$$$capture(ForkJoinTask.java:373)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java)
at
java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
at
java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
at
java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)
> org.apache.plc4x.java.api.exceptions.PlcConnectionException: Error creating
> channel
> -----------------------------------------------------------------------------------
>
> Key: PLC4X-326
> URL: https://issues.apache.org/jira/browse/PLC4X-326
> Project: Apache PLC4X
> Issue Type: Bug
> Components: Driver-Modbus
> Affects Versions: 0.9.0
> Reporter: DHANABALAN DURAIRAJASIVAM
> Priority: Critical
>
> Hello All,
> I have used to poll the Modbus Registers every 10 Seconds
> and for modbus connection, I have used the connection Code from example
> given. (see below).
> _try (PlcConnection plcConnection = new
> PlcDriverManager().getConnection(connectionString)) \{ ... do something with
> the connection here ... }_
>
> _Above code created in a bean and bean has been called by camel producer
> every 10 sec._
> *The Question is ,does this above code close the connection itself when
> repeatedly called by new instance? or we need to handle connection close?*
> *Exception.*
> org.apache.plc4x.java.api.exceptions.PlcConnectionException: Error creating
> channel.
> at
> org.apache.plc4x.java.spi.connection.NettyChannelFactory.createChannel(NettyChannelFactory.java:130)
> at
> org.apache.plc4x.java.spi.connection.DefaultNettyPlcConnection.connect(DefaultNettyPlcConnection.java:121)
> at
> org.apache.plc4x.java.PlcDriverManager.getConnection(PlcDriverManager.java:74)
> at com.jtc.evcharger.bean.ModbusScan.GetEvChargerData(ModbusScan.java:82)
> at jdk.internal.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> at java.base/java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.apache.camel.support.ObjectHelper.invokeMethodSafe(ObjectHelper.java:382)
> at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:494)
> at
> org.apache.camel.component.bean.MethodInfo$1.doProceed(MethodInfo.java:316)
> at
> org.apache.camel.component.bean.MethodInfo$1.proceed(MethodInfo.java:286)
> at
> org.apache.camel.component.bean.AbstractBeanProcessor.process(AbstractBeanProcessor.java:146)
> at
> org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:81)
> at
> org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:463)
> at
> org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:179)
> at
> org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64)
> at org.apache.camel.processor.Pipeline.process(Pipeline.java:184)
> at
> org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398)
> at
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210)
> at
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)
> at java.base/java.util.TimerThread.mainLoop(Unknown Source)
> at java.base/java.util.TimerThread.run(Unknown Source)
> Caused by: java.lang.IllegalStateException: failed to create a child event
> loop
> at
> io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:88)
> at
> io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:60)
> at
> io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:52)
> at
> io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:97)
> at
> io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:92)
> at
> io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:73)
> at
> io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:53)
> at
> io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:45)
> at
> org.apache.plc4x.java.spi.connection.NettyChannelFactory.getEventLoopGroup(NettyChannelFactory.java:86)
> at
> org.apache.plc4x.java.spi.connection.NettyChannelFactory.createChannel(NettyChannelFactory.java:94)
> ... 21 more
> Caused by: io.netty.channel.ChannelException: failed to open a new selector
> at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:175)
> at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:142)
> at
> io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:183)
> at
> io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:38)
> at
> io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:84)
> ... 30 more
> Caused by: java.io.IOException: Too many open files
> at java.base/sun.nio.ch.EPoll.create(Native Method)
> at java.base/sun.nio.ch.EPollSelectorImpl.<init>(Unknown Source)
> at java.base/sun.nio.ch.EPollSelectorProvider.openSelector(Unknown Source)
> at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:173)
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)