Skip to content

Commit

Permalink
Our SSH Client is expecting milliseconds when setting timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed May 15, 2023
1 parent adcc377 commit c37d69a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/lib/sftp_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion backend/model/marc_ao_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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')}")
Expand Down

0 comments on commit c37d69a

Please sign in to comment.