I have a program which interacts with a FTP server whenever the user issues a command. Here is the basic structure of my code:
from ftplib import FTP
ftp = FTP(host=host)
login_status = ftp.login(user=username, passwd=password)
while True:
command = input()
if command == "abc":
ftp.storbinary(textfile, textmessage1)
elif command == "def":
ftp.storbinary(textfile, textmessage2)
Problem is, if I wait for about 20 seconds between issuing commands (i.e if I leave the program for about 20 seconds), and tries to issue a command after the 20s gap, then this error message pops up: ftplib.error_temp: 421 Timeout - try typing a little faster next time
It is in my understanding that ftp servers have a time limit and will kick you after inactivity. I'm looking for a way to keep the FTP server busy and stop letting it kick my program off. Basically, any solution that prevents that error message from showing again.
Thanks in advance!