This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author realnehareddy
Recipients Grégoire Chauvet, Matthieu Pepin, christian.heimes, corona10, jonathan-lp, paul.moore, paulw11, realnehareddy, steve.dower, tim.golden, zach.ware
Date 2019-08-23.15:38:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566574726.74.0.62409983594.issue31727@roundup.psfhosted.org>
In-reply-to
Content
We faced the same issue while trying to copy files to an FTPS server. 
We are trying to connect to a Filezilla server. The type of encryption we are using for the FTPS is 'Require explicit FTP over TLS'.

There are the errors that my colleague and I had while trying to use the ftp.nlst() or the storbinary() functions in ftplib. 

EOF occurred in violation of protocol (_ssl.c:852)
OSError: [Errno 0] Error
 
After some research on the internet, we found a workaround on stack overflow (https://stackoverflow.com/questions/46633536/getting-a-oserror-when-trying-to-list-ftp-directories-in-python) 

Below is the code for the workaround. hoping this could help resolve the issue in the newer version. 
 
import ftplib
from ssl import SSLSocket


class ReusedSslSocket(SSLSocket):
    def unwrap(self):
        pass


class MyFTP_TLS(ftplib.FTP_TLS):
    """Explicit FTPS, with shared TLS session"""
    def ntransfercmd(self, cmd, rest=None):
        conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest)
        if self._prot_p:
            conn = self.context.wrap_socket(conn,
                                            server_hostname=self.host,
                                            session=self.sock.session)  # reuses TLS session            
            conn.__class__ = ReusedSslSocket  # we should not close reused ssl socket when file transfers finish
        return conn, size
History
Date User Action Args
2019-08-23 15:38:46realnehareddysetrecipients: + realnehareddy, paul.moore, christian.heimes, tim.golden, zach.ware, steve.dower, Matthieu Pepin, corona10, jonathan-lp, Grégoire Chauvet, paulw11
2019-08-23 15:38:46realnehareddysetmessageid: <1566574726.74.0.62409983594.issue31727@roundup.psfhosted.org>
2019-08-23 15:38:46realnehareddylinkissue31727 messages
2019-08-23 15:38:45realnehareddycreate