NIFI-10088 Set SSH Transport Timeout using SFTP Data Timeout property

Signed-off-by: Nathan Gough <thenatog@gmail.com>

This closes #6097.
This commit is contained in:
exceptionfactory 2022-06-03 10:50:42 -05:00 committed by Nathan Gough
parent 1342ea7025
commit 4aa0d31d9f
1 changed files with 7 additions and 0 deletions

View File

@ -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)) {