From 4aa0d31d9f43848714463eda2c4d3539825b73d6 Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Fri, 3 Jun 2022 10:50:42 -0500 Subject: [PATCH] NIFI-10088 Set SSH Transport Timeout using SFTP Data Timeout property Signed-off-by: Nathan Gough This closes #6097. --- .../processors/standard/ssh/StandardSSHClientProvider.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ssh/StandardSSHClientProvider.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ssh/StandardSSHClientProvider.java index 2924934a4a..1a612c9292 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ssh/StandardSSHClientProvider.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ssh/StandardSSHClientProvider.java @@ -20,6 +20,7 @@ import net.schmizz.keepalive.KeepAlive; import net.schmizz.sshj.Config; import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.connection.Connection; +import net.schmizz.sshj.transport.Transport; import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.transport.verification.PromiscuousVerifier; import net.schmizz.sshj.userauth.keyprovider.KeyFormat; @@ -146,6 +147,12 @@ public class StandardSSHClientProvider implements SSHClientProvider { final int dataTimeout = context.getProperty(DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(); client.setTimeout(dataTimeout); + // Set Transport and Connection timeouts using Socket Data Timeout property + final Transport transport = client.getTransport(); + transport.setTimeoutMs(dataTimeout); + final Connection connection = client.getConnection(); + connection.setTimeoutMs(dataTimeout); + final boolean strictHostKeyChecking = context.getProperty(STRICT_HOST_KEY_CHECKING).asBoolean(); final String hostKeyFilePath = context.getProperty(HOST_KEY_FILE).getValue(); if (StringUtils.isNotBlank(hostKeyFilePath)) {