agoragames / haigha

AMQP Python client
BSD 3-Clause "New" or "Revised" License
160 stars 41 forks source link

TypeError: getsockaddrarg() takes exactly 2 arguments (4 given) #76

Closed vitaly-krugl closed 8 years ago

vitaly-krugl commented 9 years ago

Got the following traceback when executing Connection(host="www.google.com")

Note: I also get the same error when executing Connection() on my MacBookPro while RabbitMQ broker is not running

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-2c936482f179> in <module>()
----> 1 Connection(host="www.google.com")

/Users/vkruglikov/ossdev/haigha/haigha/connection.pyc in __init__(self, **kwargs)
    139 
    140         self._output_frame_buffer = []
--> 141         self.connect(self._host, self._port)
    142 
    143     @property

/Users/vkruglikov/ossdev/haigha/haigha/connection.pyc in connect(self, host, port)
    221         }
    222 
--> 223         self._transport.connect((host, port))
    224         self._transport.write(PROTOCOL_HEADER)
    225 

/Users/vkruglikov/ossdev/haigha/haigha/transports/socket_transport.pyc in connect(self, (host, port), klass)
     41         for _family, _socktype, _proto, _canonname, sockaddr in infos:
     42             try:
---> 43                 self._sock.connect(sockaddr)
     44                 break
     45             except socket.error as exc:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.pyc in meth(name, self, *args)
    222 
    223 def meth(name,self,*args):
--> 224     return getattr(self._sock,name)(*args)
    225 
    226 for _m in _socketmethods:

TypeError: getsockaddrarg() takes exactly 2 arguments (4 given)
vitaly-krugl commented 9 years ago

Reverting the IPv6 support commit bbfbb31b2f2a123c0398fb07a2a5100025ba4184 changes the exception to the expected:

>>> Connection(host="www.google.com")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/vkruglikov/ossdev/haigha/haigha/connection.py", line 141, in __init__
    self.connect(self._host, self._port)
  File "/Users/vkruglikov/ossdev/haigha/haigha/connection.py", line 223, in connect
    self._transport.connect((host, port))
  File "/Users/vkruglikov/ossdev/haigha/haigha/transports/socket_transport.py", line 39, in connect
    self._sock.connect((host, port))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.timeout: timed out
vitaly-krugl commented 9 years ago

Also, without the IPv6 commit, when rabbitmq is down on localhost, you get a more reasonable traceback:

>>> Connection()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/vkruglikov/ossdev/haigha/haigha/connection.py", line 141, in __init__
    self.connect(self._host, self._port)
  File "/Users/vkruglikov/ossdev/haigha/haigha/connection.py", line 223, in connect
    self._transport.connect((host, port))
  File "/Users/vkruglikov/ossdev/haigha/haigha/transports/socket_transport.py", line 39, in connect
    self._sock.connect((host, port))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 61] Connection refused
vitaly-krugl commented 8 years ago

I believe this to be addressed by PR #69