python ftp timeout_python - FTP文件传输期间Python数据通道超时 - 堆栈内存溢出
我正在嘗試使用Python的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))
我可以在文件傳輸期間連接到FTP主機(jī),沒有任何問題。 連接超時(shí)開始并關(guān)閉連接,然后該連接的日志顯示為“ 425數(shù)據(jù)通道由于不滿足最低帶寬要求而超時(shí)”。 我使用了其他FTP客戶端(Filezilla,WinSCP),并且兩者都可以連接到主機(jī)。
連接超時(shí)設(shè)置為2分鐘的日志
*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.'
連接超時(shí)設(shè)置為60秒或更短的日志此序列的順序似乎很奇怪,因?yàn)檫B接退出后會(huì)給出226 Transfer Completed 。 它不應(yīng)該說明轉(zhuǎn)移完成然后退出嗎?
*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.'
總結(jié)
以上是生活随笔為你收集整理的python ftp timeout_python - FTP文件传输期间Python数据通道超时 - 堆栈内存溢出的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python逆序数怎么求_怎么算逆序数?
- 下一篇: plsql打开sql窗口快捷键_巧用Na