NIFI-4160: SFTPTransfer connection timeout for opening channel.

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #1991.
This commit is contained in:
Koji Kawamura 2017-07-07 09:52:53 +09:00 committed by Pierre Villard
parent 50c364a793
commit e84f9a2416
1 changed files with 3 additions and 2 deletions

View File

@ -431,13 +431,14 @@ public class SFTPTransfer implements FileTransfer {
session.setPassword(password); 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(); session.connect();
this.session = session; this.session = session;
this.closed = false; this.closed = false;
sftp = (ChannelSftp) session.openChannel("sftp"); sftp = (ChannelSftp) session.openChannel("sftp");
sftp.connect(); sftp.connect(connectionTimeoutMillis);
session.setTimeout(ctx.getProperty(FileTransfer.DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue()); session.setTimeout(ctx.getProperty(FileTransfer.DATA_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue());
if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) { if (!ctx.getProperty(USE_KEEPALIVE_ON_TIMEOUT).asBoolean()) {
session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException session.setServerAliveCountMax(0); // do not send keepalive message on SocketTimeoutException