celery / kombu

Messaging library for Python.
http://kombu.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
2.85k stars 926 forks source link

Always assumes ipv4 with localhost for pyamqp #326

Open ngie-eign opened 10 years ago

ngie-eign commented 10 years ago

The code in kombu.transport.pyamqp ( https://github.com/celery/kombu/blob/master/kombu/transport/pyamqp.py#L98 ) should use socket.getaddrinfo in order to determine the host IP instead of assuming it's always 127.0.0.1

        if conninfo.hostname == 'localhost':
            conninfo.hostname = '127.0.0.1'
ask commented 10 years ago

That's a very valid point, but this is a work around for a gevent bug (or eventlet, cannot remember which) where it cannot resolve localhost for some reason. So presumably the same problem would be present if using getaddrinfo. Maybe it could use some way to verify that the address work and if not attempt the ipv6 equivalent.

ngie-eign commented 10 years ago

Perhaps, but this could be conditionalized depending on the version of the third party library and documented as a caveat. Right now it's not really documented.

Korijn commented 2 years ago

Just want to point out that when you're working with WSL2 to run RabbitMQ in a docker container, the port is forwarded from the WSL2 VM to the host, but only on localhost and not on 127.0.0.1. This if statement basically kills my development setup!

auvipy commented 2 years ago

contributions to improve this will be highly regarded.