Minimizing Connection reset by peer exceptions



This may be more of a socket question than a python question; not sure.

Using this code to instantiate/connect/set options
connectionHandle = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
errorStatus = connectionHandle.connect_ex((ipAddress, port))
connectionHandle.setsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO,
60000)

Using this code to send:
retSendAll = connectionHandle.sendall(messageToHost)

Followed by this code to recv:
bufferSize = 500000
responseBuffer = connectionHandle.recv(bufferSize)

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'.

.



Relevant Pages

  • Re: fc2, ssh client/server, kernel 494
    ... Error = Connection reset by peer ... closed connection to service sharename$ ...
    (linux.redhat.misc)
  • What does it mean ?????
    ... Oct 20 13:41:09 constellation smbd: getpeername failed. ... Connection reset by peer ... writing 4 bytes to socket 5: ERRNO = Connection reset by peer ...
    (Fedora)
  • Re: Sockets: code works locally but fails over LAN
    ... Without these corrections I got these error messages ... ..socketerror.: error: (10054, 'Connection reset by peer') ...
    (comp.lang.python)
  • Re: Minimizing Connection reset by peer exceptions
    ... (10054, 'Connection reset by peer') ... Generally this just means the connection has closed through some ... Do note, though, that if you aren't using some means of handling the connections asynchronously then your server will normally only queue a very limited number of connections. ...
    (comp.lang.python)
  • Re: Coping with abnormal network disconections
    ... signaled to you when an incoming FIN is received from remote peer. ... exiting the thread or abort the connection rapidly. ... > interconnected with data paths (not part of the network). ...
    (microsoft.public.win32.programmer.networks)