473,382 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

10060, 'Operation timed out'

I am using following script to connect to the server and i try the
connection for 1000 times. Some times it succeeds for all the 1000
times,but some times it fails with error:-
10060, 'Operation timed out'. When it fails with the abover error, it
seems timed out time is 20 seconds. Is there a way I can increase the
timedout time for FTP?

from ftplib import FTP
import time
import sys

host = sys.argv[1]
port = sys.argv[2]

for x in range(1000):
try:
y = time.time()
ftp = FTP()
ftp.connect(host,port)
ftp.login('a','a')
try:
print ftp.sendcmd('pass x')
except:
print sys.exc_value
ftp.close()
except:
print sys.exc_value
r = time.time()
print "Timeout %d %d %((r-y),x)

when there is error in connecting, it comes to the outer except and
prints the value of r-y as 21. How i can increase this timeout time? or
this error indicates something else?

Please let me know asap,

Jan 18 '06 #1
11 4335
Sumit Acharya wrote:
I am using following script to connect to the server and i try the
connection for 1000 times. Some times it succeeds for all the 1000
times,but some times it fails with error:-
10060, 'Operation timed out'. When it fails with the abover error, it
seems timed out time is 20 seconds. Is there a way I can increase the
timedout time for FTP?

from ftplib import FTP
import time
import sys

host = sys.argv[1]
port = sys.argv[2]

for x in range(1000):
try:
y = time.time()
ftp = FTP()
ftp.connect(host,port)
ftp.login('a','a')
try:
print ftp.sendcmd('pass x')
except:
print sys.exc_value
ftp.close()
except:
print sys.exc_value
r = time.time()
print "Timeout %d %d %((r-y),x)

when there is error in connecting, it comes to the outer except and
prints the value of r-y as 21. How i can increase this timeout time? or
this error indicates something else?

Please let me know asap,

In a single-threaded program you can import the socket module and then
use the socket.setdefaulttimeout() function to establish a longer timeout.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 18 '06 #2
can u please modify the script that i have posted with your suggestion,
it will help me to a certain extent.

Thanks

Jan 18 '06 #3
Sumit Acharya wrote:
can u please modify the script that i have posted with your suggestion,
it will help me to a certain extent.

Thanks

from ftplib import FTP
import time
import sys
import socket

socket.setdefaulttimeout(60)
host = sys.argv[1]
port = sys.argv[2]

for x in range(1000):
try:
y = time.time()
ftp = FTP()
ftp.connect(host,port)
ftp.login('a','a')
try:
print ftp.sendcmd('pass x')
except:
print sys.exc_value
ftp.close()
except:
print sys.exc_value
r = time.time()
print "Timeout %d %d %((r-y),x)

--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 18 '06 #4
Hi Steve,

It didnt help, i am getting same error.

Jan 18 '06 #5
Sumit Acharya wrote:
Hi Steve,

It didnt help, i am getting same error.

After 20 seconds or 60?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 18 '06 #6
After 20 seconds only.

Jan 18 '06 #7
Sumit Acharya wrote:
After 20 seconds only.

Of course I now realise there's no default timeout on sockets anyway, so
that likely wasn't the problem.

Which statement is failing?

You would actually get much more information without the try/except
clauses, as they are stopping the traceback from being printed - if the
error is occurring deep in the ftplib you will actually see "what and
where" with a full traceback. Your loop should read:

for x in range(1000):
ftp = FTP()
ftp.connect(host,port)
ftp.login('a','a')
print ftp.sendcmd('pass x')
ftp.close()

Try running the script without both try/excepts and then post the full
traceback, please. You can forget about the timings for now. It may well
be an FTP server loading issue, but a traceback will give more information.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 18 '06 #8
Hi Steve,

Thanks, I have started the run without try and except block, I will
update with the findings tomm.
Please keep this thread on for you so that I can get the solution

Jan 18 '06 #9
Hi Steve,
this is the trace I have got:-
Traceback (most recent call last):
File "sumit1.py", line 39, in ?
ftp.connect(host,port)
File "C:\programs\packages\python24\lib\ftplib.py", line 129, in
connect
raise socket.error, msg
socket.error: (10060, 'Operation timed out')

Jan 19 '06 #10
Sumit Acharya wrote:
Hi Steve,
this is the trace I have got:-
Traceback (most recent call last):
File "sumit1.py", line 39, in ?
ftp.connect(host,port)
File "C:\programs\packages\python24\lib\ftplib.py", line 129, in
connect
raise socket.error, msg
socket.error: (10060, 'Operation timed out')

So the FTP server is refusing your connection, I suspect. There's no way
the client can control the time it takes to do that.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Jan 19 '06 #11
Ok, so need to see on the server side.

Jan 19 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: willitfw | last post by:
Does anyone know how to prevent this error from occurring: IOError: (10060, 'Operation timed out'). I am using the following code without any luck. Obviously I am missing something. import...
0
by: Ajay Abhyankar | last post by:
Hi, I am trying to upload zip files using ftplib module. The server has Vsftpd 2.0.3 installed on it. I was able to succesfully upload files using ftplib and Vsftpd on the server locally...
1
by: Joško Šugar | last post by:
I have a data transfer between an c# application and web service. The application is in local network and connects to the internet thru a gateway. Connection is ADSL. Web service is on the remote...
5
by: Sachin Surana | last post by:
We use HttpWebRequest to send the request at a URL. But some times the method GetResponse throws a time out exception. But when we check the IIS logs, there is no such entry. So the request never...
4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
2
by: tlan | last post by:
Hi, I got this error when I move my web service to Windows2003 server. I spent hours scouting on the internet and could find any answer. Please help!!! I the webservice is timeout between 1...
3
by: JuHui | last post by:
I wrote a script to get 100 pages from a server. like below: 1:import httplib 2:conns = httplib.HTTPConnection("www.mytest.com") 3:conn.request("GET", "/") sometimes a socket error was...
10
by: Jim Underwood | last post by:
I am having a problem with my web page timng out while retrieving a long runnign report (90-120 seconds. I have tried modifying several settings in various places and cannot get it to run for more...
0
by: Jinshi | last post by:
Hello, everyone, I am quite new to python and I don't know how to solve this problem. I hope someone can help me. I just did a test in python shell: Traceback (most recent call last): File...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.