plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Feinauer <>
Subject Re: Reconnect of driver 2
Date Tue, 26 Mar 2019 13:43:55 GMT
Hi Gunther,

thats really great to hear : )
When I remember correctly the idea was...

1. Extend the PlcConnection interface with a "ping()" method (Boolean? Throw Exception if
not possible?)
2. Implement the Ping functionality for each plc with a sensible "operation" (not sure what
this could be for S7... read the SLZ or something?)
3. Use this feature as "keep alive" e.g. for the PooledDriverManager

does that make sense?


Am 26.03.19, 13:55 schrieb "Gunther Gruber" <>:

    Sure I like to contribute. I guess by that you mean checking out the 
    code and create a pull request with something working.
    I like your idear with the ping check. I will focus on implementing a 
    function for the ping check, which can be reused later.
    > Hi Gunther,
    > good catch : )
    > In fact, the isConnected() implementation is currently not soo god.
    > In fact it checks if the underlying communication channel from netty is connected
(which does not know that it is disconnected yet, in your case).
    > We already had discussions to introduce a real "request" based implementation like
"ping()" which sends a request.
    > Furthermore, for your use case there is the PooledDriverManager which does implicitly
what you do... throws away a not working connection and issues a new one, if needed, but that’s
a separate topic.
    > I think we should spend some effort into this "ping" functionality.
    > Perhaps you can even assist with the implementation Gunther, what do you think?
    > Julian
    > Am 26.03.19, 11:19 schrieb "Gunther Gruber" <>:
    >      Put it another way, isConnected does not work as i expect it
    >      plcConnection.isConnected() returns true even when i disconnect the vpn (maybe
of some tcp/ip keepalive?)
    >      this is the snippet of code which i expect to work (instead of the thread which
reconnects ever 10 minutes)
    >      while (doCollect) {
    >        try {
    >          if (plcConnection == null || plcConnection.isConnected() == false) {
    >            plcConnection = initPLC(config.get(CONNECTION_KEY));
    >          }
    >        } catch (PlcConnectionException e) {
    >          logger.log(Level.WARNING, "error connecting with driver", e);
    >          plcConnection = null;
    >          incrementalSleep();
    >          break;
    >        }
    >        // Create a new read request:
    >        // - Give the single item requested the alias name "value"
    >        PlcReadRequest.Builder builder = plcConnection.readRequestBuilder();
    >      Gunther Gruber

View raw message