This may be more of a socket question than a python question; not sure.
Using this code to instantiate/connect/set options
connectionHandl e = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
errorStatus = connectionHandl e.connect_ex((i pAddress, port))
connectionHandl e.setsockopt(so cket.SOL_SOCKET , socket.SO_RCVTI MEO,
60000)
Using this code to send:
retSendAll = connectionHandl e.sendall(messa geToHost)
Followed by this code to recv:
bufferSize = 500000
responseBuffer = connectionHandl e.recv(bufferSi ze)
Occasionally (perhaps 5% of the time) the following exception gets
raised:
(10054, 'Connection reset by peer')
Are there any changes I can make to the code above to eliminate the
10054 errors or to reduce the probability of encountering the 10054
error? Are there any settings that make the 'Connection reset by
peer' condition less likely?
Other posts on this subject seem to suggest that this can only be
handled by:
1) detecting the 10054 error
2) issuing a message explaining the 'connection reset' condition
followed by something along the lines of 'try again later'. 3 14120 mi************@ yahoo.com wrote: Occasionally (perhaps 5% of the time) the following exception gets raised:
(10054, 'Connection reset by peer')
Generally this just means the connection has closed through some
unusual means, perhaps by being turned off, or a network cable being
unplugged, or a timeout along the way, etc. 5% is a high figure, but
perhaps you connect to hosts that are unreliable for some reason.
You don't have control over this really; just make sure you handle the
exception. Such is life, when dealing with networking.
--
Ben Sizer
Ben Sizer wrote: mi************@ yahoo.com wrote:
Occasionall y (perhaps 5% of the time) the following exception gets raised:
(10054, 'Connection reset by peer')
Generally this just means the connection has closed through some unusual means, perhaps by being turned off, or a network cable being unplugged, or a timeout along the way, etc. 5% is a high figure, but perhaps you connect to hosts that are unreliable for some reason.
You don't have control over this really; just make sure you handle the exception. Such is life, when dealing with networking.
Do note, though, that if you aren't using some means (threading,
forking, etc) of handling the connections asynchronously then your
server will normally only queue a very limited number of connections
(usually 5 at most).
So if your service takes a while to run then it's possible that
connection requests will be rejected when the queue is full, which might
*possibly* result in the error you are seeing.
Feel free to ignore this if you only have one client at a time.
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/
Steve Holden wrote: Do note, though, that if you aren't using some means (threading, forking, etc) of handling the connections asynchronously then your server will normally only queue a very limited number of connections (usually 5 at most).
The example given by the original poster seemed to be a client (using
connect_ex) rather than a server, so I think this would only be an
issue if the code was connecting to the same host repeatedly in quick
succession.
--
Ben Sizer This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Donnal Walter |
last post by:
On Windows XP I am able to connect to a remote telnet server from the
command prompt using:
telnet nnn.nnn.nnn.nnn 23
where nnn.nnn.nnn.nnn is the IP address of the host. But using
telnetlib, this code returns the traceback that follows:
import telnetlib
host = 'nnn.nnn.nnn.nnn'
|
by: Bernd |
last post by:
Hello,
i have a problem with my network code.
What i want to do is, send an UDP-packet and check if i get an
icmp-reply type 3 (dest. unreachable).
the code looks like that so far:
..
..
|
by: Joe Lester |
last post by:
I'm seeing this message a couple times per day in my postgres log:
2004-04-20 14:47:46 LOG: could not receive data from client:
Connection reset by peer
What does it mean? I've seen in the archives that it seems to be some
kind of system error. Does anyone know how serious this message is?
Does it mean that one of my clients is failing to connect or, worse,
losing data in transit?
|
by: Van_Gogh |
last post by:
Hi,
I am learning how to use the smtplib module, but am having some very
early problems, maybe because I don't understand it.
So, am I correct that by following the example in the Python:
>>> import smtplib
>>> server = smtplib.SMTP('localhost')
>>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',
"""To: jcaesar@example.org
|
by: ahlongxp |
last post by:
Hi, everyone,
I'm implementing a simple client/server protocol.
Now I've got a situation:
client will send server command,header paires and optionally body.
server checks headers and decides whether to accept(read) the body.
if server decided to throw(dump) the request's body, it'll send back a
response message, such as "resource already exists" and close the
connection.
| |
by: chrispoliquin |
last post by:
Hi,
I have a small Python script to fetch some pages from the internet.
There are a lot of pages and I am looping through them and then
downloading the page using urlretrieve() in the urllib module.
The problem is that after 110 pages or so the script sort of hangs and
then I get the following traceback:
Traceback (most recent call last):
|
by: fscali |
last post by:
Hi,
we are using a client c# console application to test a web service
which uses Easy Soap.
We are currently stuck in a strange problem which occurs only in a
particular method call to the web service. In this case the connection
is established, data begins to be transferred from the server to the
client, but after about 260 ~ 270 KBytes the C# client send a tcp rst
flag to the server and after that the connection is closed, and data
is...
|
by: jhaski |
last post by:
I made a python program that crawls a major website and collects a bunch of data. I have found that I get "connection reset by peer" issues on almost every page I crawl. I keep a log of every page, which gives me this error, so I can recrawl that page, but is there a way to not get that error?
|
by: gigs |
last post by:
I connect to web site with httplib.HTTPConnection. after some time i get this
error: 104 "connection reset by peer". What exception i should use to catche
this error
thx!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |