I am trying to upload a file via python and ftplib. Code below. File shows up on server data is written but transfer never completes, and i get no error messages, it just gets stuck at "150 Data transfer starting" (Uploading works when using FileZilla). (I am very new to this so please explain.. :)
with ftplib.FTP_TSL(host, user, passw) as ftp:
print(ftp.connect(host, port))
print(ftp.login(user, passw))
print(ftp.getwelcome())
print(ftp.set_debuglevel(2))
print(ftp.prot_p())
print(ftp.set_pasv(True))
print(ftp.cwd("/test/IFC_"))
with open("test2.txt", "rb") as f:
ftp.storbinary('STOR test2.txt', f)
FILEZILLA LOG:
Status: Looks up the address of the ftp.o.rendra.io
Status: Connects to 52.58.230.251:21...
Status: Connection provisioned, waiting for welcome message...
resp: 220 Welcome to the Rendra O FTP server
cmd: AUTH TLS
resp: 234 AUTH command OK
Status: Initializing TLS...
Status: TLS connection provisioned.
cmd: USER ********
resp: 331 User name ok, password required
cmd: PASS *********
respective: 230 Password ok, continue
cmd: OPTS UTF8 ON
resp: 200 UTF8 mode enabled
cmd: PBSZ 0
resp: 200 OK
cmd: PROT P
resp: 200 OK
Status: Logged in
Status: Starts sending C:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\test2.txt
cmd: CWD /test/IFC_
resp: 250 Directrory changed to /test/IFC_
cmd: TYPE A
resp: 200 Type set to ASCII
cmd: PASV
resp: 227 Entering Passive Mode (52,58,230,251,9,196)
cmd: STOR test2.txt
resp: 150 Data transfer starting
resp: 226 OK, received 95 bytes
Status: File transfer successful, transferred 95 bytes in 1 second
Status: Retrieving directory listing for "/test/IFC_"...
cmd: TYPE I
respective: 200 Type set to binary
cmd: PASV
resp: 227 Entering Passive Mode (52,58,230,251,8,232)
cmd: LIST
resp: 150 Opening ASCII mode data connection for file list
resp: 226 Closing data connection, late 84 bytes
Status: Directory listing of "/test/IFC_" succeeded
Status: Disconnected from the server
TERMINAL (Transfer never completes):
get '200 OK\n'
resp '200 OK'
cmd 'PROT P'
put 'PROT P\r\n'
get '200 OK\n'
resp '200 OK'
200 OK
None
cmd 'CWD /test/IFC_'
put 'CWD /test/IFC_\r\n'
get '250 Directory changed to /test/IFC_\n'
resp '250 Directory changed to /test/IFC_'
250 Directory changed to /test/IFC_
cmd 'TYPE I'
put 'TYPE I\r\n'
get '200 Type set to binary\n'
resp '200 Type set to binary'
cmd 'PASV'
put 'PASV\r\n'
get '227 Entering Passive Mode (52,58,230,251,9,170)\n'
resp '227 Entering Passive Mode (52,58,230,251,9,170)'
cmd 'STOR test2.txt'
put 'STOR test2.txt\r\n'
get '150 Data transfer starting\n'
resp '150 Data transfer starting'
After following the steps at ftplib storbinary with FTPS is hanging/never completing i did get a 450 error. Now terminal output is as follows:
...
get '150 Data transfer starting\n'
resp '150 Data transfer starting'
get '450 error during transfer: UploadDocument failed to upload to S3: ReadRequestBody: read upload data failed\n'
resp '450 error during transfer: UploadDocument failed to upload to S3: ReadRequestBody: read upload data failed'
cmd 'QUIT'
put 'QUIT\r\n'
get 'caused by: read tcp 192.168.80.2:2322->xx.xxx.xx.xxx:61552: read: connection timed out\n'
resp 'caused by: read tcp 192.168.80.2:2322->xx.xxx.xx.xxx:61552: read: connection timed out'
Traceback (most recent call last):
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\test.py", line 23, in
ftp.storbinary('STOR wall_export.ifc', f)
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 508, in storbinary
return self.voidresp()
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 259, in voidresp
resp = self.getresp()
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 252, in getresp
raise error_temp(resp)
my_ftplib.error_temp: 450 error during transfer: UploadDocument failed to upload to S3: ReadRequestBody: read upload data failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\test.py", line 23, in
ftp.storbinary('STOR wall_export.ifc', f)
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 132, in exit
self.quit()
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 658, in quit
resp = self.voidcmd('QUIT')
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 286, in voidcmd
return self.voidresp()
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 259, in voidresp
resp = self.getresp()
File "c:\Users\SEOHKR\Desktop\Python\Projekt\Sperlings backe\my_ftplib.py", line 255, in getresp
raise error_proto(resp)
my_ftplib.error_proto: caused by: read tcp 192.168.80.2:2322->xx.xxx.xx.xxx:61552: read: connection timed out