FTP without timeout?

C

Chris

How do I setup an FTP connection without timeout using ftplib.FTP?

I've tried
ftp = ftplib.FTP('server')
ftp.login('user', 'xxx')
ftp.sock.settimeout(None)
or
ftp.sock.settimeout(3600)
or
ftp.sock.setblocking(True)
but it always timeout after 10 minutes of inactivity.
The server allows idle up to 240 minutes before disconnecting.

Please help! Thanks in advance.

Chris
 
S

Steve Holden

Chris said:
How do I setup an FTP connection without timeout using ftplib.FTP?

I've tried
ftp = ftplib.FTP('server')
ftp.login('user', 'xxx')
ftp.sock.settimeout(None)
or
ftp.sock.settimeout(3600)
or
ftp.sock.setblocking(True)
but it always timeout after 10 minutes of inactivity.
The server allows idle up to 240 minutes before disconnecting.

Please help! Thanks in advance.

Chris
Try putting

import socket
socket.setdefaulttimeout(240*60)

at the start of your code to see whether this makes a difference. This
ensures that the socket timeout is established before a connection is
made to the remote endpoint.

Though frankly, from the documentation, since there doesn't appear to be
a default timeont on sockets, I'm not sure where this bizarre ten minute
timeout is coming from. The string "time" doesn't appear at all in the
ftplib source, so I'm somewhat stumped.

Are you sure the server doesn't require some sort of keepalive from the
client?

regards
Steve
 
D

Dave Brueck

Steve said:
Chris said:
How do I setup an FTP connection without timeout using ftplib.FTP?
[snip]
Though frankly, from the documentation, since there doesn't appear to be
a default timeont on sockets, I'm not sure where this bizarre ten minute
timeout is coming from. The string "time" doesn't appear at all in the
ftplib source, so I'm somewhat stumped.

Are you sure the server doesn't require some sort of keepalive from the
client?

An intermediate firewall could also need a keepalive - it's not uncommon for
them to kill idle connections after a few minutes.

-Dave
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top