Re: Connection died after disconnection

2020-07-27 Thread Stefano Bossi
Hi Chris,

I follow your suggestion and I have opened a Jira ticket with a couple
of capture.

Here is the link:
https://issues.apache.org/jira/browse/PLC4X-220

Regards,
Steafano Bossi


On 25/07/2020 10:33, Christofer Dutz wrote:
> Hi Stefano, 
>
> Connection reset looks like the remote hung up. 
> In general the code looks good. One thing you could do would be to do
> a wireshark recording. Then we can identify what's going wrong. 
>
> In that case ideally create a jira issue and attach that pcapng file
> to that. 
>
> Chris
> 
> *Von:* Stefano Bossi 
> *Gesendet:* Samstag, 25. Juli 2020 09:06
> *An:* dev@plc4x.apache.org 
> *Betreff:* Re: Connection died after disconnection
>  
>
> Dear Chris,
>
> I tried to follow your suggestions but I still have some problem.
>
> I wrote a test application to show you the problem and ask suggestions.
> Basically my app fire a couple of thread which read a field in a DB
> continuously; the problem is that after some seconds one of the two
> thread fire an untrappable exception and the software dies.
> Here is my code:
>
> |package it.fox; import org.apache.logging.log4j.LogManager; import
> org.apache.logging.log4j.Logger; import
> org.apache.plc4x.java.api.PlcConnection; import
> org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager;
> public class App { private static final Logger logger =
> LogManager.getLogger(App.class); public static void main(String[]
> args) { try { PlcConnection plcConnection = new
> PooledPlcDriverManager().getConnection("s7://192.168.1.192?controller-type=S7_1200");
> if (plcConnection.getMetadata().canRead() ) { Poller01 poller01 = new
> Poller01(); poller01.start(plcConnection); Poller02 poller02 = new
> Poller02(); poller02.start(plcConnection); } else { logger.error("This
> connection doesn't support reading."); Thread.sleep(5000); } } catch
> (Exception exception) { logger.error("Error connecting to the PLC",
> exception); } } } |
> |package it.fox; import java.util.concurrent.TimeUnit; import
> org.apache.logging.log4j.LogManager; import
> org.apache.logging.log4j.Logger; import
> org.apache.plc4x.java.api.PlcConnection; import
> org.apache.plc4x.java.api.messages.PlcReadRequest; import
> org.apache.plc4x.java.api.messages.PlcReadResponse; public class
> Poller01 implements Runnable { private static final Logger logger =
> LogManager.getLogger(Poller01.class); private Thread thread; private
> PlcConnection plcConnection; @Override public void run() {
> PlcReadRequest.Builder requestBuilder =
> plcConnection.readRequestBuilder(); requestBuilder.addItem("data",
> "%DB1:262.0:INT"); PlcReadRequest readRequest =
> requestBuilder.build(); while(true){ try { PlcReadResponse response =
> readRequest.execute().get(5000, TimeUnit.MILLISECONDS); if (response
> != null){ logger.info("poller01 = {}", response.getPlcValue("data") );
> Thread.sleep( (int) Math.floor(Math.random() * 100) ); } else {
> logger.error("No response from PLC in reading polling variable");
> break; } } catch (Exception e) { logger.error("Poller01 Exception",
> e); } } } /** * Start the thread */ public void start(PlcConnection
> plcConnection) { this.plcConnection = plcConnection;
> logger.info("Starting poller01 thread"); if (thread == null) { thread
> = new Thread(this, "poller01"); thread.start(); } } } |
> |package it.fox; import java.util.concurrent.TimeUnit; import
> org.apache.logging.log4j.LogManager; import
> org.apache.logging.log4j.Logger; import
> org.apache.plc4x.java.api.PlcConnection; import
> org.apache.plc4x.java.api.messages.PlcReadRequest; import
> org.apache.plc4x.java.api.messages.PlcReadResponse; public class
> Poller02 implements Runnable{ private static final Logger logger =
> LogManager.getLogger(Poller02.class); private Thread thread; private
> PlcConnection plcConnection; @Override public void run() {
> PlcReadRequest.Builder requestBuilder =
> plcConnection.readRequestBuilder(); requestBuilder.addItem("data",
> "%DB1:0.0:DINT"); PlcReadRequest readRequest = requestBuilder.build();
> while(true){ try { PlcReadResponse response =
> readRequest.execute().get(5000, TimeUnit.MILLISECONDS); if (response
> != null){ logger.info("poller02 = {}", response.getPlcValue("data") );
> Thread.sleep( (int) Math.floor(Math.random() * 500) ); } else {
> logger.error("No response from PLC in reading polling variable");
> break; } } catch (Exception e) { logger.error("Poller01 Exception",
> e); } } } /** * Start the thread */ public void start(PlcConnection
> plcConnec

Re: Connection died after disconnection

2020-07-25 Thread Christofer Dutz
Hi Stefano,

Connection reset looks like the remote hung up.
In general the code looks good. One thing you could do would be to do a 
wireshark recording. Then we can identify what's going wrong.

In that case ideally create a jira issue and attach that pcapng file to that.

Chris

Von: Stefano Bossi 
Gesendet: Samstag, 25. Juli 2020 09:06
An: dev@plc4x.apache.org 
Betreff: Re: Connection died after disconnection


Dear Chris,

I tried to follow your suggestions but I still have some problem.

I wrote a test application to show you the problem and ask suggestions.
Basically my app fire a couple of thread which read a field in a DB 
continuously; the problem is that after some seconds one of the two thread fire 
an untrappable exception and the software dies.
Here is my code:

package it.fox;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager;

public class App {

private static final Logger logger = LogManager.getLogger(App.class);
public static void main(String[] args) {

try {
PlcConnection plcConnection = new 
PooledPlcDriverManager().getConnection("s7://192.168.1.192?controller-type=S7_1200");
if (plcConnection.getMetadata().canRead() ) {
Poller01 poller01 = new Poller01();
poller01.start(plcConnection);
Poller02 poller02 = new Poller02();
poller02.start(plcConnection);

} else {
logger.error("This connection doesn't support reading.");
Thread.sleep(5000);
}
} catch (Exception exception) {
logger.error("Error connecting to the PLC", exception);
}
}
}


package it.fox;

import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;

public class Poller01 implements Runnable {

private static final Logger logger = LogManager.getLogger(Poller01.class);
private Thread thread;
private PlcConnection plcConnection;

@Override
public void run() {
PlcReadRequest.Builder requestBuilder = 
plcConnection.readRequestBuilder();
requestBuilder.addItem("data", "%DB1:262.0:INT");
PlcReadRequest readRequest = requestBuilder.build();
while(true){
try {
PlcReadResponse response = readRequest.execute().get(5000, 
TimeUnit.MILLISECONDS);
if (response != null){
logger.info("poller01 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 100) );
} else {
logger.error("No response from PLC in reading polling 
variable");
break;
}
} catch (Exception e) {
logger.error("Poller01 Exception", e);
}
}
}

/**
 * Start the thread
 */
public void start(PlcConnection plcConnection) {
this.plcConnection = plcConnection;
logger.info("Starting poller01 thread");
if (thread == null) {
thread = new Thread(this, "poller01");
thread.start();
}
}

}


package it.fox;

import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;

public class Poller02 implements Runnable{

private static final Logger logger = LogManager.getLogger(Poller02.class);
private Thread thread;
private PlcConnection plcConnection;

@Override
public void run() {
PlcReadRequest.Builder requestBuilder = 
plcConnection.readRequestBuilder();
requestBuilder.addItem("data", "%DB1:0.0:DINT");
PlcReadRequest readRequest = requestBuilder.build();
while(true){
try {
PlcReadResponse response = readRequest.execute().get(5000, 
TimeUnit.MILLISECONDS);
if (response != null){
logger.info("poller02 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 500) );
} else {
logger.error("No response from PLC in reading polling 
variable");
break;
}
} catch (Exception e) {
   

Re: Connection died after disconnection

2020-07-25 Thread Stefano Bossi
Dear Chris,

I tried to follow your suggestions but I still have some problem.

I wrote a test application to show you the problem and ask suggestions.
Basically my app fire a couple of thread which read a field in a DB
continuously; the problem is that after some seconds one of the two
thread fire an untrappable exception and the software dies.
Here is my code:

|package it.fox; import org.apache.logging.log4j.LogManager; import
org.apache.logging.log4j.Logger; import
org.apache.plc4x.java.api.PlcConnection; import
org.apache.plc4x.java.utils.connectionpool.PooledPlcDriverManager;
public class App { private static final Logger logger =
LogManager.getLogger(App.class); public static void main(String[] args)
{ try { PlcConnection plcConnection = new
PooledPlcDriverManager().getConnection("s7://192.168.1.192?controller-type=S7_1200");
if (plcConnection.getMetadata().canRead() ) { Poller01 poller01 = new
Poller01(); poller01.start(plcConnection); Poller02 poller02 = new
Poller02(); poller02.start(plcConnection); } else { logger.error("This
connection doesn't support reading."); Thread.sleep(5000); } } catch
(Exception exception) { logger.error("Error connecting to the PLC",
exception); } } } |

|package it.fox; import java.util.concurrent.TimeUnit; import
org.apache.logging.log4j.LogManager; import
org.apache.logging.log4j.Logger; import
org.apache.plc4x.java.api.PlcConnection; import
org.apache.plc4x.java.api.messages.PlcReadRequest; import
org.apache.plc4x.java.api.messages.PlcReadResponse; public class
Poller01 implements Runnable { private static final Logger logger =
LogManager.getLogger(Poller01.class); private Thread thread; private
PlcConnection plcConnection; @Override public void run() {
PlcReadRequest.Builder requestBuilder =
plcConnection.readRequestBuilder(); requestBuilder.addItem("data",
"%DB1:262.0:INT"); PlcReadRequest readRequest = requestBuilder.build();
while(true){ try { PlcReadResponse response =
readRequest.execute().get(5000, TimeUnit.MILLISECONDS); if (response !=
null){ logger.info("poller01 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 100) ); } else {
logger.error("No response from PLC in reading polling variable"); break;
} } catch (Exception e) { logger.error("Poller01 Exception", e); } } }
/** * Start the thread */ public void start(PlcConnection plcConnection)
{ this.plcConnection = plcConnection; logger.info("Starting poller01
thread"); if (thread == null) { thread = new Thread(this, "poller01");
thread.start(); } } } |

|package it.fox; import java.util.concurrent.TimeUnit; import
org.apache.logging.log4j.LogManager; import
org.apache.logging.log4j.Logger; import
org.apache.plc4x.java.api.PlcConnection; import
org.apache.plc4x.java.api.messages.PlcReadRequest; import
org.apache.plc4x.java.api.messages.PlcReadResponse; public class
Poller02 implements Runnable{ private static final Logger logger =
LogManager.getLogger(Poller02.class); private Thread thread; private
PlcConnection plcConnection; @Override public void run() {
PlcReadRequest.Builder requestBuilder =
plcConnection.readRequestBuilder(); requestBuilder.addItem("data",
"%DB1:0.0:DINT"); PlcReadRequest readRequest = requestBuilder.build();
while(true){ try { PlcReadResponse response =
readRequest.execute().get(5000, TimeUnit.MILLISECONDS); if (response !=
null){ logger.info("poller02 = {}", response.getPlcValue("data") );
Thread.sleep( (int) Math.floor(Math.random() * 500) ); } else {
logger.error("No response from PLC in reading polling variable"); break;
} } catch (Exception e) { logger.error("Poller01 Exception", e); } } }
/** * Start the thread */ public void start(PlcConnection plcConnection)
{ this.plcConnection = plcConnection; logger.info("Starting poller02
thread"); if (thread == null) { thread = new Thread(this, "poller02");
thread.start(); } } } |

The exception the code throw is:

|[INFO ] 22:59:19.767 org.apache.plc4x.java.PlcDriverManager.() -
Instantiating new PLC Driver Manager with class loader
jdk.internal.loader.ClassLoaders$AppClassLoader@55054057 [INFO ]
22:59:19.770 org.apache.plc4x.java.PlcDriverManager.() -
Registering available drivers... [INFO ] 22:59:19.774
org.apache.plc4x.java.PlcDriverManager.() - Registering driver for
Protocol s7 (Siemens S7 (Basic)) [INFO ] 22:59:19.908
org.apache.plc4x.java.transport.tcp.TcpChannelFactory.configureBootstrap()
- Configuring Bootstrap with Configuration{local-rack=1, local-slot=1,
remote-rack=0, remot-slot=0, pduSize=1024, maxAmqCaller=8,
maxAmqCallee=8, controllerType='S7_1200'} [INFO ] 22:59:20.158
it.fox.Poller01.start() - Starting poller01 thread [INFO ] 22:59:20.160
it.fox.Poller02.start() - Starting poller02 thread [INFO ] 22:59:20.244
it.fox.Poller01.run() - poller01 = 7 [INFO ] 22:59:20.286
it.fox.Poller02.run() - poller02 = 12139 [INFO ] 22:59:20.347
it.fox.Poller01.run() - poller01 = 7 [INFO ] 22:59:20.400
it.fox.Poller01.run() - poller01 = 7 [INFO ] 22:59:20.530
it.fox.Poller01.run() - poller01 = 7 

Re: Connection died after disconnection

2020-07-22 Thread Stefano Bossi
Ok,

thanks for the fast reply, I will check the documentation and I will let
you know.

Regards,
S.


On 21/07/2020 19:21, Christofer Dutz wrote:
> Hi Stefano,
>
> First of all, welcome on our list... We'll do our best to help you.
>
> Have you tried using our connection pool? Cause this should handle the 
> connection state if the connection is disturbed. Also the scraper is a tool 
> for collecting data periodically. This in combination with the connection 
> pool should be what you are looking for.
>
> Please find the documentation to using both on our website.
>
> Hope that helps,
> Chris
> 
> Von: Stefano Bossi 
> Gesendet: Dienstag, 21. Juli 2020 15:56
> An: Apache PLC4X 
> Betreff: Connection died after disconnection
>
>
> Dear forum,
>
> I am trying to develop a simple poller for my S7 PLC ST_1200.
> I need just a simple thread in java which read a value and report it, anyway 
> this must be robust to any problem on the network.
> I mean I would like to cope with these situation:
>
>   *   PLC not responding;
>   *   network issues;
>
> The software should normally read a value from the plc in 200 ms and if 
> something bad happen, wait for 5 second and retry to read in a normal way.
>
> I wrote some code but when I found a problem.
> This is my code:
>
> public void run() {
> ConfigurationDataProvider configurationDataProvider = 
> ConfigurationDataProvider.getInstance();
> try {
> PlcConnection plcConnection = new 
> Client().getClient(configurationDataProvider.getPlcConnectionString()).getPlcConnection();
> PlcReadRequest.Builder requestBuilder = 
> plcConnection.readRequestBuilder();
> requestBuilder.addItem("pollingVariable", 
> configurationDataProvider.getPlcPollingVariable());
> PlcReadRequest readRequest = requestBuilder.build();
> while (true){
> if (plcConnection.isConnected()){
> try {
> PlcReadResponse response = 
> readRequest.execute().get(CONNECTION_TIME_OUT, TimeUnit.MILLISECONDS);
> if (response != null ){
> logger.debug("Polling variable: {}", 
> response.getPlcValue("pollingVariable"));
> } else {
> logger.error("No response from PLC in reading 
> polling variable");
> break;
> }
> } catch (TimeoutException timeoutException){
> logger.error("Time out Exception in polling PLC", 
> timeoutException);
> Thread.sleep(5000);
> }
> 
> Thread.sleep(configurationDataProvider.getPollingInterval());
> }
> }
>
> } catch (Exception e) {
> logger.error("Interrupted Exception", e);
> }
> }
>
>
> When I try to disconnect the cable, netty comply with an internal error and 
> my application dies without a way to recover.
> Here are the logs:
>
> [ERROR] 15:33:38.830 it.fox.plcreader.Poller.run() - Time out Exception in 
> polling PLC
> java.util.concurrent.TimeoutException: null
> at java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
> at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?]
> at it.fox.plcreader.Poller.run(Poller.java:34) [main/:?]
> Poller.java:34
> at java.lang.Thread.run(Unknown Source) [?:?]
> [ERROR] 15:33:49.333 it.fox.plcreader.Poller.run() - Time out Exception in 
> polling PLC
> java.util.concurrent.TimeoutException: null
> at java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
> at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?]
> at it.fox.plcreader.Poller.run(Poller.java:34) [main/:?]
> Poller.java:34
> at java.lang.Thread.run(Unknown Source) [?:?]
> [WARN ] 15:33:54.308 
> io.netty.channel.DefaultChannelPipeline.onUnhandledInboundException() - An 
> exceptionCaught() event was fired, and it reached at the tail of the 
> pipeline. It usually means the last handler in the pipeline did not handle 
> the exception.
> java.io.IOException: Operation timed out
> at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:?]
> at sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[?:?]
> at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[?:?]
> at sun.nio.ch.IOUtil.read(Unknown Source) ~[?:?]
> at sun.nio.ch.IOUtil.read(Unknown S

Re: Connection died after disconnection

2020-07-21 Thread Christofer Dutz
Hi Stefano,

First of all, welcome on our list... We'll do our best to help you.

Have you tried using our connection pool? Cause this should handle the 
connection state if the connection is disturbed. Also the scraper is a tool for 
collecting data periodically. This in combination with the connection pool 
should be what you are looking for.

Please find the documentation to using both on our website.

Hope that helps,
Chris

Von: Stefano Bossi 
Gesendet: Dienstag, 21. Juli 2020 15:56
An: Apache PLC4X 
Betreff: Connection died after disconnection


Dear forum,

I am trying to develop a simple poller for my S7 PLC ST_1200.
I need just a simple thread in java which read a value and report it, anyway 
this must be robust to any problem on the network.
I mean I would like to cope with these situation:

  *   PLC not responding;
  *   network issues;

The software should normally read a value from the plc in 200 ms and if 
something bad happen, wait for 5 second and retry to read in a normal way.

I wrote some code but when I found a problem.
This is my code:

public void run() {
ConfigurationDataProvider configurationDataProvider = 
ConfigurationDataProvider.getInstance();
try {
PlcConnection plcConnection = new 
Client().getClient(configurationDataProvider.getPlcConnectionString()).getPlcConnection();
PlcReadRequest.Builder requestBuilder = 
plcConnection.readRequestBuilder();
requestBuilder.addItem("pollingVariable", 
configurationDataProvider.getPlcPollingVariable());
PlcReadRequest readRequest = requestBuilder.build();
while (true){
if (plcConnection.isConnected()){
try {
PlcReadResponse response = 
readRequest.execute().get(CONNECTION_TIME_OUT, TimeUnit.MILLISECONDS);
if (response != null ){
logger.debug("Polling variable: {}", 
response.getPlcValue("pollingVariable"));
} else {
logger.error("No response from PLC in reading 
polling variable");
break;
}
} catch (TimeoutException timeoutException){
logger.error("Time out Exception in polling PLC", 
timeoutException);
Thread.sleep(5000);
}

Thread.sleep(configurationDataProvider.getPollingInterval());
}
}

} catch (Exception e) {
logger.error("Interrupted Exception", e);
}
}


When I try to disconnect the cable, netty comply with an internal error and my 
application dies without a way to recover.
Here are the logs:

[ERROR] 15:33:38.830 it.fox.plcreader.Poller.run() - Time out Exception in 
polling PLC
java.util.concurrent.TimeoutException: null
at java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?]
at it.fox.plcreader.Poller.run(Poller.java:34) [main/:?]
Poller.java:34
at java.lang.Thread.run(Unknown Source) [?:?]
[ERROR] 15:33:49.333 it.fox.plcreader.Poller.run() - Time out Exception in 
polling PLC
java.util.concurrent.TimeoutException: null
at java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?]
at it.fox.plcreader.Poller.run(Poller.java:34) [main/:?]
Poller.java:34
at java.lang.Thread.run(Unknown Source) [?:?]
[WARN ] 15:33:54.308 
io.netty.channel.DefaultChannelPipeline.onUnhandledInboundException() - An 
exceptionCaught() event was fired, and it reached at the tail of the pipeline. 
It usually means the last handler in the pipeline did not handle the exception.
java.io.IOException: Operation timed out
at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:?]
at sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[?:?]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[?:?]
at sun.nio.ch.IOUtil.read(Unknown Source) ~[?:?]
at sun.nio.ch.IOUtil.read(Unknown Source) ~[?:?]
at sun.nio.ch.SocketChannelImpl.read(Unknown Source) ~[?:?]
at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253) 
~[netty-buffer-4.1.47.Final.jar:4.1.47.Final]
PooledByteBuf.java:253
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133) 
~[netty-buffer-4.1.47.Final.jar:4.1.47.Final]
AbstractByteBuf.java:1133
at 
io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
 ~[netty-transport-4.1.47.Final.jar:4.1.47.Final]
NioSocketChannel.java:350
at 
io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
 [netty-transport-4.1.47.Final.jar:4.1.47.Final]
AbstractNioByteChannel.java:148

Connection died after disconnection

2020-07-21 Thread Stefano Bossi
Dear forum,

I am trying to develop a simple poller for my S7 PLC ST_1200.
I need just a simple thread in java which read a value and report it,
anyway this must be robust to any problem on the network.
I mean I would like to cope with these situation:

  * PLC not responding;
  * network issues;

The software should normally read a value from the plc in 200 ms and if
something bad happen, wait for 5 second and retry to read in a normal way.

I wrote some code but when I found a problem.
This is my code:

|public void run() { ConfigurationDataProvider configurationDataProvider
= ConfigurationDataProvider.getInstance(); try { PlcConnection
plcConnection = new
Client().getClient(configurationDataProvider.getPlcConnectionString()).getPlcConnection();
PlcReadRequest.Builder requestBuilder =
plcConnection.readRequestBuilder();
requestBuilder.addItem("pollingVariable",
configurationDataProvider.getPlcPollingVariable()); PlcReadRequest
readRequest = requestBuilder.build(); while (true){ if
(plcConnection.isConnected()){ try { PlcReadResponse response =
readRequest.execute().get(CONNECTION_TIME_OUT, TimeUnit.MILLISECONDS);
if (response != null ){ logger.debug("Polling variable: {}",
response.getPlcValue("pollingVariable")); } else { logger.error("No
response from PLC in reading polling variable"); break; } } catch
(TimeoutException timeoutException){ logger.error("Time out Exception in
polling PLC", timeoutException); Thread.sleep(5000); }
Thread.sleep(configurationDataProvider.getPollingInterval()); } } }
catch (Exception e) { logger.error("Interrupted Exception", e); } } |

When I try to disconnect the cable, netty comply with an internal error
and my application dies without a way to recover.
Here are the logs:

|[ERROR] 15:33:38.830 it.fox.plcreader.Poller.run() - Time out Exception
in polling PLC java.util.concurrent.TimeoutException: null at
java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?] at
it.fox.plcreader.Poller.run(Poller.java:34) [main/:?] Poller.java:34 at
java.lang.Thread.run(Unknown Source) [?:?] [ERROR] 15:33:49.333
it.fox.plcreader.Poller.run() - Time out Exception in polling PLC
java.util.concurrent.TimeoutException: null at
java.util.concurrent.CompletableFuture.timedGet(Unknown Source) ~[?:?]
at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[?:?] at
it.fox.plcreader.Poller.run(Poller.java:34) [main/:?] Poller.java:34 at
java.lang.Thread.run(Unknown Source) [?:?] [WARN ] 15:33:54.308
io.netty.channel.DefaultChannelPipeline.onUnhandledInboundException() -
An exceptionCaught() event was fired, and it reached at the tail of the
pipeline. It usually means the last handler in the pipeline did not
handle the exception. java.io.IOException: Operation timed out at
sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:?] at
sun.nio.ch.SocketDispatcher.read(Unknown Source) ~[?:?] at
sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source) ~[?:?] at
sun.nio.ch.IOUtil.read(Unknown Source) ~[?:?] at
sun.nio.ch.IOUtil.read(Unknown Source) ~[?:?] at
sun.nio.ch.SocketChannelImpl.read(Unknown Source) ~[?:?] at
io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
~[netty-buffer-4.1.47.Final.jar:4.1.47.Final] PooledByteBuf.java:253 at
io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133)
~[netty-buffer-4.1.47.Final.jar:4.1.47.Final] AbstractByteBuf.java:1133
at
io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
~[netty-transport-4.1.47.Final.jar:4.1.47.Final]
NioSocketChannel.java:350 at
io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
[netty-transport-4.1.47.Final.jar:4.1.47.Final]
AbstractNioByteChannel.java:148 at
io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
[netty-transport-4.1.47.Final.jar:4.1.47.Final] NioEventLoop.java:714 at
io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
[netty-transport-4.1.47.Final.jar:4.1.47.Final] NioEventLoop.java:650 at
io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
[netty-transport-4.1.47.Final.jar:4.1.47.Final] NioEventLoop.java:576 at
io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
[netty-transport-4.1.47.Final.jar:4.1.47.Final] NioEventLoop.java:493 at
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
[netty-common-4.1.47.Final.jar:4.1.47.Final]
SingleThreadEventExecutor.java:989 at
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
[netty-common-4.1.47.Final.jar:4.1.47.Final] ThreadExecutorMap.java:74
at
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[netty-common-4.1.47.Final.jar:4.1.47.Final]
FastThreadLocalRunnable.java:30 at java.lang.Thread.run(Unknown Source)
[?:?] |

Googling I found this Stack Overflow