addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcredit-cardcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobe--smallglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1launch-new-window--smalllight-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

FTP TLS failure (first BIG Python problem)

From: user 3.
Sent on: Monday, March 12, 2012 1:40 AM
Philly Python folks,

I've NEVER had a big Python problem till this week.   We promised our biggest client (Amtrak) that we could automate all out FTP with them.
I gave this little thought since we have done lots of SFTP with Paramiko module and also with the regular FTP module.

However, we ran into a BIG roadblock last week trying to use FTP with TLS.
No matter what, after a successful connection, we can NOT get a directory listing without the  [Errno 10060] shown below.
We tried everything you can think of.  The timeout setting in the FTP_TLS line makes no difference.  The error comes back in 20 seconds.

Now, when  we use CORE FTP on the same machine, we can see the listing just fine,  And YES, everything is set to Passive mode by default.
We have tried both Pyhton 2.6 and 2.7 (we moved the FTPLIB into Python 2.6 from 2.7 Lib.  We are standardized on Python 2.6).

Except for Amtrak's password change to 'ourpassword' , the 13 lines of code below are exactly as is.
We can not use our full code until  this test works.

Does ANYONE have a clue?  This has become a big issue -  to the point where we may have to use  new language for all out FTP.
For instance, I can get this to work with 4th Dimension calling a  Core FTP  Batch file.   I want to avoid that it at all possible.

Python has not failed me yet.  SO,  I' m hoping its some server "mystery" I am missing.

Thanks ahead of time - I know this is a smart group.  So I'm hopeful  :)


import socket
from ftplib import FTP_TLS

ftps = FTP_TLS(host = '[masked]', user = 'AMTRAK', passwd = 'ourpassword', timeout = 240)
print ftps.pwd()
except socket.error, e:
   print "ERROR %s" % e

`------------------D­EBUG LEVEL 2 OUTPUT BELOW------------

*cmd* 'CWD /Outbound/CMNotesTxt­'
*put* 'CWD /Outbound/CMNotesTxt­\r\n'
*get* '250 CWD successful. "/Outbound/CMNotesTx­t" is current directory.\r\n'
*resp* '250 CWD successful. "/Outbound/CMNotesTx­t" is current directory.'
*cmd* 'PWD'
*put* 'PWD\r\n'
*get* '257 "/Outbound/CMNotesTx­t" is current directory.\r\n'
*resp* '257 "/Outbound/CMNotesTx­t" is current directory.'
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Type set to A\r\n'
*resp* '200 Type set to A'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (192,168,1,130,4,0)\­r\n'
*resp* '227 Entering Passive Mode (192,168,1,130,4,0)'­
ERROR [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
*cmd* 'QUIT'
*put* 'QUIT\r\n'
*get* '221 Goodbye\r\n'
*resp* '221 Goodbye'

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy