简体   繁体   中英

Python 3.6 ftps file download - SSLEOFError: EOF occurred in violation of protocol (_ssl.c:841)

I'm attempting to write a script that goes to a Filezilla server every once in a while to retrieve files. I have administration rights over the Filezilla server and configuration, but not over the rest of the system or network, but requests can be made.

Code:

from ftplib import FTP_TLS

host="11.211.171.41"
ftps = FTP_TLS(host)
ftps.login()
ftps.prot_p()
ftps.dir()
#-r--r--r-- 1 ftp ftp        5636096 Aug 07 00:50 master.mdf
#-r--r--r-- 1 ftp ftp        2097152 Aug 07 00:50 mastlog.ldf
filename = "master.mdf"
with open(filename, 'wb') as f:
    ftps.retrbinary('RETR {}'.format(filename), f.write)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fcontreras/scripts/ftps/ftps.py", line 29, in get
    ftps.retrbinary('RETR {}'.format(filename), f.write)
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ftplib.py", line 442, in retrbinary
    with self.transfercmd(cmd, rest) as conn:
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ftplib.py", line 399, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ftplib.py", line 801, in ntransfercmd
    server_hostname=self.host)
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ssl.py", line 407, in wrap_socket
    _context=self, _session=session)
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ssl.py", line 814, in __init__
    self.do_handshake()
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ssl.py", line 1068, in do_handshake
    self._sslobj.do_handshake()
  File "/home/fcontreras/miniconda3/envs/ftp/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:841)

So the main point is to fix the error, but i'm having a hard time finding out what (_ssl.c:841) means, I'm not sure where to start looking.

Found the issue, the SSLEOFError is misleading, the error is cause because the databases aren't readable.

I didn't check this to begin with because the permissions showed as:

#-r--r--r-- 1 ftp ftp        5636096 Aug 07 00:50 master.mdf
#-r--r--r-- 1 ftp ftp        2097152 Aug 07 00:50 mastlog.ldf

They seem to be permanently are open by the database engine that made them, and windows won't allow the user or the FTP server to read the file to transfer.

Hopefully this will help reduce google time for someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM