问候语
我正在尝试使用以下脚本将文件上传到FTPS服务器(Wing FTP Server / Cerberus FTP Server 8)。
from ftplib import FTP_TLS
ftps = FTP_TLS('192.168.133.69')
ftps.login('1011', '7c52xK9')
ftps.prot_p()
filename = 'upload.pdf'
myfile = open(filename, 'rb')
ftps.storbinary('STOR %s' % filename, myfile)
myfile.close()
ftps.close()
但我一直收到这个错误。
line 7, in <module>
ftps.storbinary('STOR %s' % filename, myfile)
File "C:\Python27\lib\ftplib.py", line 769, in storbinary
conn.unwrap()
File "C:\Python27\lib\ssl.py", line 823, in unwrap
s = self._sslobj.shutdown()
error: [Errno 0] Error
这是FTPS服务器日志。
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 220 Wing FTP Server ready... (UNREGISTERED WING FTP SERVER)
[03] Thu, 02 Feb 2017 19:41:23 (0000062) AUTH TLS
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 234 AUTH command OK. Initializing TLS connection.
[03] Thu, 02 Feb 2017 19:41:23 (0000062) USER 1011
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 331 Password required for 1011
[03] Thu, 02 Feb 2017 19:41:23 (0000062) PASS **********
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 230 User 1011 logged in.
[03] Thu, 02 Feb 2017 19:41:23 (0000062) PBSZ 0
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 200 Command okay. PBSZ=0.
[03] Thu, 02 Feb 2017 19:41:23 (0000062) PROT P
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 200 Encrypting Data Channel.
[03] Thu, 02 Feb 2017 19:41:23 (0000062) TYPE I
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 200 Type set to I
[03] Thu, 02 Feb 2017 19:41:23 (0000062) PASV
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 227 Entering Passive Mode (192,168,133,69,4,21)
[03] Thu, 02 Feb 2017 19:41:23 (0000062) STOR upload.pdf
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 150 Opening BINARY mode data connection for file transfer.
[04] Thu, 02 Feb 2017 19:41:23 (0000062) 226 File received successful. Transferred:0Bytes;Average speed is:0.000KB/s
谁能告诉我有什么问题?!!
PS:我不知道它是否重要,但我可以轻松地从这个FTPS服务器下载,只能上传到它。
提前致谢
编辑1:
我尝试用FileZilla
作为“Martin Prikryl”建议,现在我有以下错误。
line 7, in <module>
ftps.storbinary('STOR %s' % filename, myfile)
File "C:\Python27\lib\ftplib.py", line 760, in storbinary
conn = self.transfercmd(cmd, rest)
File "C:\Python27\lib\ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python27\lib\ftplib.py", line 713, in ntransfercmd
server_hostname=self.host)
File "C:\Python27\lib\ssl.py", line 363, in wrap_socket
_context=self)
File "C:\Python27\lib\ssl.py", line 611, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 840, in do_handshake
self._sslobj.do_handshake()
SSLEOFError: EOF occurred in violation of protocol (_ssl.c:661)
这是FileZilla服务器日志。
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> Connected on port 21, sending welcome message...
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> 220-FileZilla Server 0.9.59 beta
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> 220-written by Tim Kosse (tim.kosse@filezilla-project.org)
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> 220 Please visit https://filezilla-project.org/
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> AUTH TLS
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> 234 Using authentication type TLS
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> TLS connection established
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> USER 1011
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> 331 Password required for 1011
(000002)2017/02/03 11:00:54 ق.ظ - (not logged in) (127.0.0.1)> PASS *******
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 230 Logged on
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> PBSZ 0
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 200 PBSZ=0
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> PROT P
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 200 Protection level set to P
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> TYPE I
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 200 Type set to I
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> PASV
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 227 Entering Passive Mode (127,0,0,1,231,157)
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> STOR upload.pdf
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 150 Opening data channel for file upload to server of "/upload.pdf"
(000002)2017/02/03 11:00:54 ق.ظ - 1011 (127.0.0.1)> 450 TLS session of data connection has not resumed or the session does not match the control connection
(000002)2017/02/03 11:02:54 ق.ظ - 1011 (127.0.0.1)> 421 Connection timed out.
(000002)2017/02/03 11:02:54 ق.ظ - 1011 (127.0.0.1)> disconnected.
答案 0 :(得分:1)
在您和服务器之间的路上可能会有一些防火墙/ NAT /代理干扰传输连接。
由于在拆除TLS / SSL连接期间似乎发生了问题,在实际传输完成后,某些客户端可能只是选择忽略该错误(或者他们甚至没有注意到它)。