Any help would be appreciated. I have googled for two days now and tried everything I could find. Thinking it might be PASV issue with internal IP, Reuse session ID and things I dont even know what they did but I tried.
Ultimately want to upload a file to an external site I do not control. Was trying to use storbinary and got the same error, so I simplified to a dir listing and still get the error. Not sure what else to try. Running Python 3.10.7
Exception has occurred: TimeoutError
[WinError 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
File "XXXXXXX.py", line 96, in <module>
ftp.dir()
Very Basic Code:
with ftplib.FTP_TLS('XXXXX') as ftp:
ftp.set_debuglevel(1)
ftp.login('XXXXXX', 'XXXXXXX')
ftp.prot_p()
ftp.set_pasv(True)
ftp.dir()
ftp.close()
Debug shows:
*cmd* 'AUTH TLS'
*resp* '234 AUTH TLS successful'
*cmd* 'PBSZ 0'
*resp* '200 PBSZ 0 successful'
*cmd* 'PROT P'
*resp* '200 Protection set to Private'
*cmd* 'TYPE A'
*resp* '200 Type set to A'
*cmd* 'PASV'
*resp* '227 Entering Passive Mode (3,87,37,152,196,95).'
*cmd* 'QUIT'
*resp* '221 Goodbye.'
If I conenct via WinSCP it works fine:
2022-09-07 09:33:36.427 OPTS UTF8 ON
< 2022-09-07 09:33:36.461 200 UTF8 set to on
> 2022-09-07 09:33:36.461 PBSZ 0
< 2022-09-07 09:33:36.495 200 PBSZ 0 successful
> 2022-09-07 09:33:36.495 PROT P
< 2022-09-07 09:33:36.530 200 Protection set to Private
. 2022-09-07 09:33:36.530 Session upkeep
. 2022-09-07 09:33:36.563 Connected
. 2022-09-07 09:33:36.563 Got reply 1 to the command 1
. 2022-09-07 09:33:36.563 --------------------------------------------------------------------------
. 2022-09-07 09:33:36.563 Using FTP protocol.
. 2022-09-07 09:33:36.563 Doing startup conversation with host.
> 2022-09-07 09:33:36.579 PWD
< 2022-09-07 09:33:36.613 257 "/" is the current directory
. 2022-09-07 09:33:36.613 Got reply 1 to the command 16
. 2022-09-07 09:33:36.613 Changing directory to "/".
> 2022-09-07 09:33:36.613 CWD /
< 2022-09-07 09:33:36.648 250 CWD command successful
. 2022-09-07 09:33:36.648 Got reply 1 to the command 16
. 2022-09-07 09:33:36.648 Getting current directory name.
> 2022-09-07 09:33:36.648 PWD
< 2022-09-07 09:33:36.682 257 "/" is the current directory
. 2022-09-07 09:33:36.682 Got reply 1 to the command 16
. 2022-09-07 09:33:36.734 Retrieving directory listing...
> 2022-09-07 09:33:36.734 TYPE A
< 2022-09-07 09:33:36.769 200 Type set to A
> 2022-09-07 09:33:36.770 PASV
< 2022-09-07 09:33:36.804 227 Entering Passive Mode (52,91,110,136,197,134).
> 2022-09-07 09:33:36.804 MLSD
. 2022-09-07 09:33:36.804 Connecting to 52.91.110.136:50566 ...
< 2022-09-07 09:33:36.876 150 Opening ASCII mode data connection for MLSD
. 2022-09-07 09:33:36.877 Session ID reused
. 2022-09-07 09:33:36.877 Using TLSv1.2, cipher TLSv1.2: ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA, ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD
. 2022-09-07 09:33:36.877 TLS connection established
. 2022-09-07 09:33:36.935 modify=20220906233223;perm=flcdmpe;type=cdir;unique=27UE026C66DFCF056E6;UNIX.group=99;UNIX.mode=0777;UNIX.owner=99; .
. 2022-09-07 09:33:36.935 modify=20220906233223;perm=flcdmpe;type=pdir;unique=27UE026C66DFCF056E6;UNIX.group=99;UNIX.mode=0777;UNIX.owner=99; ..
. 2022-09-07 09:33:36.935 modify=20220905013650;perm=flcdmpe;type=dir;unique=27UCC6B22EAEE6D4E2E;UNIX.group=99;UNIX.mode=0777;UNIX.owner=99; release
. 2022-09-07 09:33:36.935 Session upkeep
. 2022-09-07 09:33:36.986 Data connection closed
< 2022-09-07 09:33:36.986 226 Transfer complete
. 2022-09-07 09:33:36.986 Directory listing successful