This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch fix-plc4x-problem in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit e151534be02c145e123bb6f49a92ffb02223f5ea Author: Philipp Zehnder <[email protected]> AuthorDate: Fri Nov 14 13:15:11 2025 +0100 fix: Trigger backoff strategy when plc is not connected --- .../connection/ContinuousPlcRequestReader.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/generic/connection/ContinuousPlcRequestReader.java b/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/generic/connection/ContinuousPlcRequestReader.java index d8f0e13916..89c302eed7 100644 --- a/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/generic/connection/ContinuousPlcRequestReader.java +++ b/streampipes-extensions/streampipes-connectors-plc/src/main/java/org/apache/streampipes/extensions/connectors/plc/adapter/generic/connection/ContinuousPlcRequestReader.java @@ -76,18 +76,28 @@ public class ContinuousPlcRequestReader processPlcReadResponse(readResponse); } else { LOG.error("Not connected to PLC with connection string {}", settings.connectionString()); + handleFailingPlcRead(); } } catch (Exception e) { - handleFailingPlcRead(e.getMessage()); + handleFailingPlcReadAndRemoveFromCache(e.getMessage()); } } - private void handleFailingPlcRead(String problem) { + private void handleFailingPlcReadAndRemoveFromCache(String problem) { // ensure that the cached connection manager removes the broken connection if (connectionManager instanceof SpCachedPlcConnectionManager) { ((SpCachedPlcConnectionManager) connectionManager).removeCachedConnection(settings.connectionString()); } + LOG.error( + "Error while reading from PLC with connection string {}. Setting adapter to idle for {} attempts. {} ", + settings.connectionString(), idlePullsBeforeNextAttempt, problem + ); + + handleFailingPlcRead(); + } + + private void handleFailingPlcRead() { // Increase backoff counter on failure if (idlePullsBeforeNextAttempt == 0) { idlePullsBeforeNextAttempt = 1; @@ -95,11 +105,6 @@ public class ContinuousPlcRequestReader idlePullsBeforeNextAttempt = Math.min(idlePullsBeforeNextAttempt * 2, MAX_IDLE_PULLS); } - LOG.error( - "Error while reading from PLC with connection string {}. Setting adapter to idle for {} attempts. {} ", - settings.connectionString(), idlePullsBeforeNextAttempt, problem - ); - currentIdlePulls = 0; }
