1 Replies - 1243 Views - Last Post: 13 March 2013 - 08:24 PM Rate Topic: -----

#1 TheLoneFellow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 13

Pyro4 "Connection Reset by Peer" after 4 concurrent connection

Posted 06 March 2013 - 05:24 PM

I have searched and searched and can't find an answer. I am trying to open a Pyro connection between two unix devices. I can connect 4 times to the device using a Pyro4 Proxy with an identical URI string. On the fifth connection, the instance hangs on my get data function call. It goes through the core.py pyro package and ends up waiting to get the data. Very occasionally, one of these open connections that was created after the fourth one will throw a ConnectionClosedError exception that looks like this:
ConnectionClosedError("receiving: connection lost: "+str(x))
ConnectionClosedError: receiving: connection lost: [Errno 104] Connection reset by peer



If I haven't been clear, the following is what causes this issue: -Open 4 connections on different SSH sessions to the device and run repeated tests which setup a pyro proxy. (These work just fine and complete without error) -Open more connections, all hanging on my call to get data. They hang for at least 5 minutes, and some will infrequently raise the above exception. -Not all of them will do this. Once 1 of the 4 running tests finishes, the 5th test that was hanging will pick up and finish just fine. The others will follow, but never any more than 4 at a time.

Lastly, the following code (in socketutil.py) is where the exception is actually happening:
def receiveData(sock, size):
    """Retrieve a given number of bytes from a socket.
    It is expected the socket is able to supply that number of bytes.
    If it isn't, an exception is raised (you will not get a zero length result
    or a result that is smaller than what you asked for). The partial data that
    has been received however is stored in the 'partialData' attribute of
    the exception object."""
    try:
        retrydelay=0.0
        msglen=0
        chunks=[]
        if hasattr(socket, "MSG_WAITALL"):
            # waitall is very convenient and if a socket error occurs,
            # we can assume the receive has failed. No need for a loop,
            # unless it is a retryable error.
            # Some systems have an erratic MSG_WAITALL and sometimes still return
            # less bytes than asked. In that case, we drop down into the normal
            # receive loop to finish the task.
           while True:
            try:
                data=sock.recv(size, socket.MSG_WAITALL)
                if len(data)==size:
                    return data
                # less data than asked, drop down into normal receive loop to finish
                msglen=len(data)
                chunks=[data]
                break
            except socket.timeout:
                raise TimeoutError("receiving: timeout")
            except socket.error:
                x=sys.exc_info()[1]
                err=getattr(x, "errno", x.args[0])
                if err not in ERRNO_RETRIES:
                    #################HERE!!###################
                    raise ConnectionClosedError("receiving: connection lost: "+str(x))
                time.sleep(0.00001+retrydelay)  # a slight delay to wait before retrying
                retrydelay=__nextRetrydelay(retrydelay)


Would really appreciate some direction here. Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: Pyro4 "Connection Reset by Peer" after 4 concurrent connection

#2 TheLoneFellow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 13

Re: Pyro4 "Connection Reset by Peer" after 4 concurrent connection

Posted 13 March 2013 - 08:24 PM

Okay, it was an issue with the server side configuration of Pyro4. The minimum threads number was set to 4 and didn't create new ones when needed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1