From c37d69a1961fb9d5409542199b05c39b563fee8f Mon Sep 17 00:00:00 2001 From: James Bullen Date: Mon, 15 May 2023 14:02:57 +1000 Subject: [PATCH] Our SSH Client is expecting milliseconds when setting timeout --- backend/lib/sftp_uploader.rb | 4 ++-- backend/model/marc_ao_exporter.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/lib/sftp_uploader.rb b/backend/lib/sftp_uploader.rb index 32e2e1a..272a370 100644 --- a/backend/lib/sftp_uploader.rb +++ b/backend/lib/sftp_uploader.rb @@ -11,8 +11,8 @@ def initialize(hostname, username, password, opts = {}) @ssh_client = Java::net.schmizz.sshj.SSHClient.new @ssh_client.addHostKeyVerifier(Java::net.schmizz.sshj.transport.verification.PromiscuousVerifier.new) - if (connect_timeout = opts.fetch(:connect_timeout, nil)) - @ssh_client.set_connect_timeout(connect_timeout) + if (connect_timeout = opts.fetch(:connect_timeout_seconds, nil)) + @ssh_client.set_connect_timeout(connect_timeout * 1000) end @ssh_client.connect(hostname, 22) diff --git a/backend/model/marc_ao_exporter.rb b/backend/model/marc_ao_exporter.rb index 6b12fe3..5b539a6 100644 --- a/backend/model/marc_ao_exporter.rb +++ b/backend/model/marc_ao_exporter.rb @@ -49,7 +49,7 @@ def self.run sftp = SFTPUploader.new(AppConfig[:marcao_sftp_host], AppConfig[:marcao_sftp_user], AppConfig[:marcao_sftp_password], - :connect_timeout => AppConfig[:marcao_sftp_timeout]) + :connect_timeout_seconds => AppConfig[:marcao_sftp_timeout]) begin sftp.upload(export_file_path, File.join(AppConfig[:marcao_sftp_path], File.basename(export_file_path))) @@ -60,6 +60,7 @@ def self.run break rescue => e Log.warn("marcao: Upload to SFTP failed: #{$!}") + error = e.inspect if (retry_count + 1) < max_retries remaining_retries = max_retries - retry_count - 1 Log.warn("marcao: Will retry #{remaining_retries} more time#{((remaining_retries == 1) ? '' : 's')}")