user1598655
user1598655

Reputation: 169

python multiprocessing socket.error: [Errno 111] Connection refused?

I am doing a simple server/client connection using multiprocessing in python 2.7.
When I run the client code in a seperate python shell, the connection is successful, but when I run the application as a whole, I get "socket.error: [Errno 111] Connection refused".

This is the Traceback:

Traceback (most recent call last):
  File "./kaboom", line 276, in <module>
    sequence.run(testEnv)
  File "/e/m/amoreau/test_edit/kaboom/src/kbmSequence.py", line 271, in run
    if testEnv.open() != SUCCESS:
  File "/e/m/amoreau/test_edit/kaboom/src/kbmTestEnv.py", line 518, in open
    queueManager = resultsClient.QueueServerClient()
  File "/e/m/amoreau/test_edit/kaboom/resultsClient.py", line 15, in QueueServerClient
    manager.connect()
  File "/usr/lib64/python2.6/multiprocessing/managers.py", line 474, in connect
    conn = Client(self._address, authkey=self._authkey)
  File "/usr/lib64/python2.6/multiprocessing/connection.py", line 143, in Client
    c = SocketClient(address)
  File "/usr/lib64/python2.6/multiprocessing/connection.py", line 263, in SocketClient
    s.connect(address)
  File "<string>", line 1, in connect
socket.error: [Errno 111] Connection refused  

Why does this happen? I have disabled all firewalls.

Upvotes: 9

Views: 9372

Answers (1)

Jimmy
Jimmy

Reputation: 881

Howdie, I just had this problem. I know this is an old answer, but I found the answer in a related question. It's listed below. The issue is that the client is attempting to connect to the server before the server has created the socket.

Well, that's what it was in my case. Spawning the server off into another process takes a wee bit longer then the client attempting to connect. To test, I placed a sleep call in my client and sure enough, no more error.

Python Socket Error - Connection Refused

Upvotes: 15

Related Questions