From e84f9a24164a3c939664a2259f3a0c07c20cfb97 Mon Sep 17 00:00:00 2001 From: Koji Kawamura Date: Fri, 7 Jul 2017 09:52:53 +0900 Subject: [PATCH] NIFI-4160: SFTPTransfer connection timeout for opening channel. Signed-off-by: Pierre Villard This closes #1991. --- .../apache/nifi/processors/standard/util/SFTPTransfer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java index 42fbf8dafd..a6a9e4b70b 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java @@ -431,13 +431,14 @@ public class SFTPTransfer implements FileTransfer { session.setPassword(password); } - session.setTimeout(ctx.getProperty(FileTransfer.CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); + final int connectionTimeoutMillis = ctx.getProperty(FileTransfer.CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue(); + session.setTimeout(connectionTimeoutMillis); session.connect(); this.session = session; this.closed = false; sftp = (ChannelSftp) session.openChannel("sftp"); - sftp.connect(); + sftp.connect(connectionTimeoutMillis); session.setTimeout(ctx.getProperty(FileTransfer.DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) { session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException