Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lftp timeout not working

Tags:

ftp

I am using the following command to set timeout of lftp command so that if the server is not available or is not accepting any new connection, the command ends after 10 sec.

lftp -e 'set ftp:passive-mode true; set net:timeout 10; cd /OUT; mput $filename; bye' -u mylftpuser,mypassword myhost.com

However, the timeout does not seem to work. When I run the above command on the command prompt, it retries connecting after 30 sec, 45 sect ..60 sec ...and never ends.

Am I doing something wrong here?

Thanks.

like image 293
Devang Thakkar Avatar asked Jun 13 '11 07:06

Devang Thakkar


3 Answers

It's because of the very high default of net:max-retries 1000 which is:

the maximum number of sequential tries of an operation without success. 0 means unlimited. 1 means no retries.

Change it (in your ~/.lftp config file) to something like 5 and you're good to go.

like image 89
not2qubit Avatar answered Oct 12 '22 16:10

not2qubit


I had the same problem with timeout not working when I used:

lftp -e "set net:timeout 5" -u user,pwd server

I have removed the -e "set..." part and use only lftp -u user,pwd server and the commands insert it into ~/.lftp/rc file:

cat ~/.lftp/rc
set net:timeout 5
set net:max-retries 2
set net:reconnect-interval-base 5

This works fine for me now.

like image 40
Michal Nemec Avatar answered Oct 12 '22 15:10

Michal Nemec


In the documentation you can find more information about the location of the settings and the available options. Below you can see the file locations of the settings.

On startup, lftp executes ~/.lftprc and ~/.lftp/rc (or ~/.config/lftp/rc if ~/.lftp does not exist). You can place aliases and set commands there. Some people prefer to see full protocol debug, use debug to turn the debug on.

There is also a system-wide startup file in /etc/lftp.conf. It can be in different directory, see FILES section.

like image 40
Shiva Janssens Avatar answered Oct 12 '22 16:10

Shiva Janssens