Specifying options for Net::SFTP

R

Richard Thomas

We are having issues when an automated file transfer process hangs
when using net::SFTP. This causes the whole process to hang and a
whole bunch of headaches ensue. We need to be able to give up on the
connection and carry on. I have tried adding timeout options to the
SFTP connection but they don't appear to be having any effect (The
process was just now hung up for over 32 hours). Can someone confirm
I'm using the parameters correctly?

$sftp=Net::SFTP->new ($site,(user => $username,
password => $password,
debug => 1,
ssh_args => [ options => ["SetupTimeOut
300", "ServerAliveInterval 300", "ServerAliveCountMax 3"]],
)) or die "Problem connecting to SFTP server. $!\n";

If it makes any difference, here is what the debug output of a hung
connection looks like:

Reading configuration data /home/user/.ssh/config
Reading configuration data /etc/ssh_config
Connecting to sftp.server.com, port 22.
Remote version string: SSH-2.0-5.1.0.558 SSH Tectia Server
Remote protocol version 2.0, remote software version 5.1.0.558 SSH
Tectia Server
Net::SSH::perl Version 1.30, protocol version 2.0.
No compat match: 5.1.0.558 SSH Tectia Server
Connection established.
Sent key-exchange init (KEXINIT), wait response.

And there it hangs.


Any help much appreciated.

Thanks

Rich
 
R

Ron Bergin

We are having issues when an automated file transfer process hangs
when using net::SFTP. This causes the whole process to hang and a
whole bunch of headaches ensue. We need to be able to give up on the
connection and carry on. I have tried adding timeout options to the
SFTP connection but they don't appear to be having any effect (The
process was just now hung up for over 32 hours). Can someone confirm
I'm using the parameters correctly?

$sftp=Net::SFTP->new ($site,(user => $username,
password => $password,
debug => 1,
ssh_args => [ options => ["SetupTimeOut
300", "ServerAliveInterval 300", "ServerAliveCountMax 3"]],
)) or die "Problem connecting to SFTP server. $!\n";
Try changing it to this (note the use of the { } braces instead of ( )

$sftp=Net::SFTP->new ($site,{user => $username,
password => $password,
debug => 1,
ssh_args => [ options => ["SetupTimeOut
300", "ServerAliveInterval 300", "ServerAliveCountMax 3"]],
}) or die "Problem connecting to SFTP server. $!\n";
 
R

Richard Thomas

Try changing it to this (note the use of the { } braces instead of ( )

$sftp=Net::SFTP->new ($site,{user => $username,
password => $password,
debug => 1,
ssh_args => [ options => ["SetupTimeOut
300", "ServerAliveInterval 300", "ServerAliveCountMax 3"]],
}) or die "Problem connecting to SFTP server. $!\n";

Well, the login itself usually works fine, this problem occurs
probably only one time in many hundreds. It's the passing of the
timeout options I'm not sure of.

Rich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,920
Messages
2,570,038
Members
46,449
Latest member
onedumbsquirrel

Latest Threads

Top