ebin123456 / py-amqplib

Automatically exported from code.google.com/p/py-amqplib
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Connection fails on older versions of FreeBSD #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
FreeBSD 6.2, Python 2.7.2, connection fails with

   File "/usr/local/lib/python2.7/site-packages/amqplib/client_0_8/connection.py", line 129, in __init__
     self.transport = create_transport(host, connect_timeout, ssl)
   File "/usr/local/lib/python2.7/site-packages/amqplib/client_0_8/transport.py", line 279, in create_transport
     return SSLTransport(host, connect_timeout, ssl)
   File "/usr/local/lib/python2.7/site-packages/amqplib/client_0_8/transport.py", line 179, in __init__
     super(SSLTransport, self).__init__(host, connect_timeout)
   File "/usr/local/lib/python2.7/site-packages/amqplib/client_0_8/transport.py", line 71, in __init__
     for res in socket.getaddrinfo(host, port, 0, 0, socket.SOL_TCP):
 socket.gaierror: [Errno 9] servname not supported for ai_socktype

Seems to be a FreeBSD bug, but can be worked around with this one-line patch

--- transport.py.original       Tue Sep 27 15:45:18 2011
+++ transport.py        Tue Sep 27 15:39:31 2011
@@ -68,7 +68,7 @@
                 port = int(port)

         self.sock = None
-        for res in socket.getaddrinfo(host, port, 0, 0, socket.SOL_TCP):
+        for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, 
socket.SOL_TCP):
             af, socktype, proto, canonname, sa = res
             try:
                 self.sock = socket.socket(af, socktype, proto)

Probably no reason to be looking for anything other than SOCK_STREAM, so 
perhaps it should just be in there by default.

Original issue reported on code.google.com by barry.pe...@gmail.com on 27 Sep 2011 at 8:48

GoogleCodeExporter commented 9 years ago
Fixed in revision cf8638fcc5c1

Original comment by barry.pe...@gmail.com on 28 Sep 2011 at 10:15