I'm trying to transfer a file using Python's ftplib
.
def ftps_put_file(host, user, password, ftp_file_path, processed_file):
try:
context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile='C:\\PATH\\TO\\SECURE.crt')
with FTP_TLS(host, user=user, passwd=password, context=context, timeout=10) as connection, open(processed_file, 'rb') as read_file:
connection.set_debuglevel(2)
connection.prot_p()
connection.cwd(ftp_file_path)
connection.storbinary(f"STOR {processed_file.name}", read_file)
except Exception as e:
print('Error occured in transporter.ftps_put_file: ' + str(e))
I can connect to the FTP host without any issues, but during the file transfer. The connection timeout kicks in and closes the connection, then the log for the connection says it '425 Data channel timed out due to not meeting the minimum bandwidth requirement.' I've used other FTP clients (Filezilla, WinSCP) and both are able to connect to the host.
Log with connection timeout set to 2 minutes
*cmd* 'PBSZ 0'
*put* 'PBSZ 0\r\n'
*get* '200 PBSZ command successful.\n'
*resp* '200 PBSZ command successful.'
*cmd* 'PROT P'
*put* 'PROT P\r\n'
*get* '200 PROT command successful.\n'
*resp* '200 PROT command successful.'
*cmd* 'CWD /'
*put* 'CWD /\r\n'
*get* '250 CWD command successful.\n'
*resp* '250 CWD command successful.'
*cmd* 'TYPE I'
*put* 'TYPE I\r\n'
*get* '200 Type set to I.\n'
*resp* '200 Type set to I.'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (204,58,62,196,19,199).\n'
*resp* '227 Entering Passive Mode (204,58,62,196,19,199).'
*cmd* 'STOR text.txt'
*put* 'STOR text.txt\r\n'
*get* '125 Data connection already open; Transfer starting.\n'
*resp* '125 Data connection already open; Transfer starting.'
*cmd* 'QUIT'
*put* 'QUIT\r\n'
*get* '425 Data channel timed out due to not meeting the minimum bandwidth requirement.\n'
*resp* '425 Data channel timed out due to not meeting the minimum bandwidth requirement.'
Log with connection timeout set to 60 seconds or less The sequence with this one seems weird because the connection quits then gives a 226 Transfer Completed
. Shouldn't it state that the transfer completed then quit?
*cmd* 'PBSZ 0'
*put* 'PBSZ 0\r\n'
*get* '200 PBSZ command successful.\n'
*resp* '200 PBSZ command successful.'
*cmd* 'PROT P'
*put* 'PROT P\r\n'
*get* '200 PROT command successful.\n'
*resp* '200 PROT command successful.'
*cmd* 'CWD /'
*put* 'CWD /\r\n'
*get* '250 CWD command successful.\n'
*resp* '250 CWD command successful.'
*cmd* 'TYPE I'
*put* 'TYPE I\r\n'
*get* '200 Type set to I.\n'
*resp* '200 Type set to I.'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (204,58,62,196,20,46).\n'
*resp* '227 Entering Passive Mode (204,58,62,196,20,46).'
*cmd* 'STOR text.txt'
*put* 'STOR text.txt\r\n'
*get* '125 Data connection already open; Transfer starting.\n'
*resp* '125 Data connection already open; Transfer starting.'
*cmd* 'QUIT'
*put* 'QUIT\r\n'
*get* '226 Transfer complete.\n'
*resp* '226 Transfer complete.'