plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gunther Gruber <gunther.gru...@IDA-Analytics.de>
Subject Reconnect of driver 2
Date Tue, 26 Mar 2019 10:18:50 GMT
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


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message