2017-02-02 6 views
2

が、私は、スクリプトを次のようにFTPSサーバー(ウィングFTPサーバ/ケルベロスのFTPサーバ8)にファイルをアップロードしようとしているエラーが

挨拶ftplibのパイソンで終了します。

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サーバーから簡単にダウンロードでき、それにアップロードできません。事前に

おかげ

EDIT 1: "マーティンPrikrylは" 提案し、今私はエラーを次のようにしている私はFileZillaてみました

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 ([email protected]) 
(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

サーバーのTLS/SSL実装とftplibの間に互換性がないようです。 proftpd、vsfpd、IIS、FileZillaのような、より主流のFTPサーバーに対してコードをテストしましたか? –

+0

@MartinPrikryl私はfilezillaでテストしましたが、別のエラーが発生しました。質問を編集しました(編集1)。確認していただけますか? –

+0

FileZillaサーバーの設定で*「FTP over TLS settings」*を無効にし、*「PROT Pを使用するときにデータ接続でTLSセッション再開を要求する」*。 –

答えて

1

転送接続を妨害するおそれがあるのは、おそらくあなたとサーバーの間にあるファイアウォール/ NAT /プロキシです。

TLS/SSL接続のティアダウン中に問題が発生したように見えるため、実際の転送が完了した後、一部のクライアントは単にエラーを無視する(または気付かない)ことがあります。

+0

それは問題でした、ありがとう –