Debugging "broken pipe" (in telnetlib)

S

Samuel

Hi,

When using telnetlib, the connection sometimes breaks with the
following error:

"error: (32, 'Broken pipe')"

where the traceback points to

self.sock.send(buffer)

in telnetlib.py. The problem is unreproducible, but happens fairly
often (approx. 5% of the time). Any idea how to debug such a problem?
How can I find out what broke the pipe?

-Samuel
 
S

Samuel

EPIPE results when writing to a socket for which writing has been shutdown.
This most commonly occurs when the socket has closed. You need to handle
this exception, since you can't absolutely prevent the socket from being
closed.

The exception is already caught and logged, but this is really not
good enough. By "handling this exception", do you mean that there is a
way to handle it such that the connection still works? I found some
code that attempts to retry when SIGPIPE was received, but this only
results in the same error all over again.
Why can this not be prevented (in the general case)? Unless something
fancy happened, what can cause the socket to close? Looking at the raw
data received by the connected host, the connection gets lost in mid-
stream; I can not see anything that might cause the remote side to
close the connection (in which case I'd expect a "connection reset by
peer" or something).
There might be some other change which would be appropriate, though,
if it is the case that something your application is doing is causing the
socket to be closed (for example, sending a message which the remote side
decides is invalid and causing it to close the socket explicitly from its
end).

The program is doing the same thing repeatedly and it works 95% of the
time, so I am fairly sure that nothing special is sent.
It's difficult to make any specific suggestions in that area without
knowing exactly what your program does.

Unfortunately the application is rather complex and a simple test case
is not possible.

Basically, it creates a number of daemon threads, each of which
creates a (thread local, non-shared) instance of telnetlib and
connects to a remote host. Are there any special conditions that must
be taken care of when opening a number of sockets in threads? (The
code runs on AIX 4.1, where Python supports native OS threads.)

-Samuel
 

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,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top