FTP HANGS on very slow connection

M

Michal Seidl

Hi,
I am trying to download data from remote ftp server connected through
GSM modem. The speed is slow 1kB/s. Despite the classic linux ftp
client works fine the ftp.retrbinary(),ftpretrlines() function from
ftplib hangs. I am able succesfuly login but a can not download. It has
probably something common with sockets.

Code:
***************************************
#Open ftp connection and downloads file
ftpDLoad = FTP(hostAdress)
ftpDLoad.set_debuglevel(2)
#ftpDLoad.sendcmd('USER xxxxx')
#ftpDLoad.sendcmd('PASS xxxxx')
ftpDLoad.login(userName,userPass)
#print ftpDLoad.login()

#Prints start time
print '###Starting sync.: ',datetime.today()

#Opens file for writing
fileObj = open(tmpDir + rFileName,'wb')

#Downloads file
#!!!!!!!!!!!
#ftpDLoad.retrbinary('RETR ' + rFileName, fileObj.write)
#!!!!!!!!!!!
ftpDLoad.retrlines('RETR' + rFileName)

#Closes file
fileObj.close()

#Checks the file size
ftpDLoad.cwd('modem')


Ouput:
******************************************
michal@telis:~/python$ ./jezeri_new_ftp.py
*cmd* 'USER telis'
*put* 'USER telis\r\n'
*get* '331 Password required for telis\r\n'
*resp* '331 Password required for telis'
*cmd* 'PASS ******'
*put* 'PASS ******\r\n'
*get* '230 Logged on\r\n'
*resp* '230 Logged on'
###Starting sync.: 2006-08-10 22:17:06.634695
*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'
Traceback (most recent call last):
File "./jezeri_new_ftp.py", line 43, in ?
ftpDLoad.retrlines('RETR' + rFileName)
File "/usr/lib/python2.4/ftplib.py", line 396, in retrlines
conn = self.transfercmd(cmd)
File "/usr/lib/python2.4/ftplib.py", line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python2.4/ftplib.py", line 321, in ntransfercmd
host, port = self.makepasv()
File "/usr/lib/python2.4/ftplib.py", line 299, in makepasv
host, port = parse227(self.sendcmd('PASV'))
File "/usr/lib/python2.4/ftplib.py", line 241, in sendcmd
return self.getresp()
File "/usr/lib/python2.4/ftplib.py", line 207, in getresp
resp = self.getmultiline()
File "/usr/lib/python2.4/ftplib.py", line 193, in getmultiline
line = self.getline()
File "/usr/lib/python2.4/ftplib.py", line 180, in getline
line = self.file.readline()
File "/usr/lib/python2.4/socket.py", line 332, in readline
data = self._sock.recv(self._rbufsize)
socket.error: (104, 'Connection reset by peer')

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top