Python ftp可以链接上,但是上传失败(提示链接超时)

Traceback (most recent call last):
  File "F:/Python_project/web/百度死链提交/神马/测试链接阿里服务器.py", line 22, in
    ftp.storbinary('STOR ' + localpath, fp, bufsize)
  File "H:\software\Python3.6\lib\ftplib.py", line 504, in storbinary
    with self.transfercmd(cmd, rest) as conn:
  File "H:\software\Python3.6\lib\ftplib.py", line 399, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "H:\software\Python3.6\lib\ftplib.py", line 361, in ntransfercmd
    source_address=self.source_address)
  File "H:\software\Python3.6\lib\socket.py", line 724, in create_connection
    raise err
  File "H:\software\Python3.6\lib\socket.py", line 713, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

Process finished with exit code 1

Python ftp可以链接上,但是上传失败(提示链接超时)_第1张图片
Python ftp可以链接上,但是上传失败(提示链接超时)_第2张图片

释放红框文字,即可上传成功

ftp.set_pasv(False)

python的默认ftplib启用passive(被动模式),因为被动模式会启用1024之后的端口,所以就会出现问题,把passive模式取消后,就没问题了

 

你可能感兴趣的:(Python ftp可以链接上,但是上传失败(提示链接超时))