Ticket #1274 (closed defect: invalid)

Opened 5 years ago

Last modified 5 years ago

socket.error: (53, 'Software caused connection abort')

Reported by: ghazel Owned by:
Priority: high Milestone:
Component: conch Keywords:
Cc: teratorn, ghazel, zectbumo Branch:
Author: Launchpad Bug:

Description


Change History

Changed 5 years ago by ghazel

This traceback happens every so often on FreeBSD (5.4-STABLE), using twisted 
2.1.0

Traceback (most recent call last):
--- <exception caught here> ---
 File "/usr/local/lib/python2.4/site-packages/twisted/internet/tcp.py", line 
760, in doRead

 File "/usr/local/lib/python2.4/site-packages/twisted/internet/tcp.py", line 
753, in doRead

 File "/usr/local/lib/python2.4/socket.py", line 169, in accept
   sock, addr = self._sock.accept()
socket.error: (53, 'Software caused connection abort')

Changed 5 years ago by zectbumo

Same here running amd64 FreeBSD 5.4-stable twisted 2.0.1

5.4-STABLE FreeBSD 5.4-STABLE #0: Fri Sep  9 14:02:41 PDT 2005 amd64

Twisted installed packages:
py24-twistedCore-2.0.1
py24-twistedNames-0.1.0_1
py24-twistedWeb-0.5.0_1

Traceback (most recent call last):
          File "/usr/local/lib/python2.4/site-packages/twisted/python/log.py",
line 41, in callWithContext
            return context.call({ILogContext: newCtx}, func, *args, **kw)
          File
"/usr/local/lib/python2.4/site-packages/twisted/python/context.py", line 52, in
callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File
"/usr/local/lib/python2.4/site-packages/twisted/python/context.py", line 31, in
callWithContext
            return func(*args,**kw)
          File
"/usr/local/lib/python2.4/site-packages/twisted/internet/selectreactor.py", line
139, in _doReadOrWrite
            why = getattr(selectable, method)()
        --- <exception caught here> ---
          File "/usr/local/lib/python2.4/site-packages/twisted/internet/tcp.py",
line 734, in doRead
            skt, addr = self.socket.accept()
          File "/usr/local/lib/python2.4/socket.py", line 169, in accept
            sock, addr = self._sock.accept()
        socket.error: (53, 'Software caused connection abort')

Changed 5 years ago by teratorn

misc info...
According to sys/sys/errno.h on a FreeBSD 4.11-RELEASE box:

#define ECONNABORTED    53   /* Software caused connection abort */

According to the accept(2) man page:
[ECONNABORTED]     A connection arrived, but it was closed while waiting
                   on the listen queue.

Changed 5 years ago by teratorn

Please provide more specific information regarding the circumstances under which 
these errors occur. Also, if at all possible, please provide code samples that 
reproduce the issue.

Changed 5 years ago by ghazel

There probably is no specific code that will reproduce the problem, unless you 
can manage to write something which will reliably close a connection while it's 
waiting in the listen queue - but that's just a guess.
I don't have any more specific information about how to reproduce it, because 
it seems to happen occasionally no matter what I do.

Changed 5 years ago by teratorn

Well, if the remote end is closing the connection before Twisted has the chance 
to accept() it, then it's not really a bug, per se.

There doesn't seem to be any reliable way to catch this error as the error code, 
in this case 53, doesn't seem to be standard. E.g on Linux:

include/asm-alpha/errno.h:#define ECONNABORTED 53 /* Software caused connection 
abort */
include/asm-generic/errno.h:#define ECONNABORTED 103 /* Software caused 
connection abort */
include/asm-mips/errno.h:#define ECONNABORTED 130 /* Software caused connection 
abort */

What do you think?

Changed 5 years ago by ghazel

what's wrong with: 
    from errno import ECONNABORTED
then:
elif e.args[0] == ECONNABORTED:
?

Changed 5 years ago by teratorn

OK, apart from discussing how to detect this condition, what are you expecting 
Twisted to do with it? Is this actually a problem in your app, or just log spam?

As far as detecting the condition, yeah, the errno module...
ECONNABORTED is defined on Windows, but I wouldn't bet my life that it is 
actually used or that it means the exact same thing. (Can anyone provide insight 
here?)
Otherwise, another question I have is how to detect this condition under all 
reactors? Maybe this isn't a problem, or maybe it is - I haven't looked in to 
it.

Changed 5 years ago by ghazel

Sorry, I misunderstood the question. This is just log spam - I can't imagine 
why I would need to know about an incoming connection that was never made.

Yes, on windows it is the same thing, except you can get it from "Any function 
that takes a socket as an input parameter".

Changed 5 years ago by teratorn

I think we should continue to yell about aborted connections, by default - it's 
an unusual condition that may indicate an error in the application under 
development, or the 3rd party client that Twisted is talking to, as it were. It 
could also indicate a network reliability issue.

I suggest you ignore these errors in your application. Unfortunately, if you are 
running under twistd, there isn't any good way to modify the default log 
observer yet. Otherwise, you can use the twisted.python.log API to have a look 
at the Failures before logging them.

If you would prefer that twisted caught these errors, as well as they can be 
caught, and emitted a warning, or just plain ignored them, (instead of just 
allowing the traceback) then please write a summary email (with plenty of 
detail) to the mailing list, and we'll see what people think.
Note: See TracTickets for help on using tickets.