kombu icon indicating copy to clipboard operation
kombu copied to clipboard

Always assumes ipv4 with localhost for pyamqp

Open ngie-eign opened this issue 10 years ago • 4 comments

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'

ngie-eign avatar Mar 17 '14 22:03 ngie-eign

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.

ask avatar Mar 19 '14 14:03 ask

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.

ngie-eign avatar Apr 08 '14 01:04 ngie-eign

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!

Korijn avatar Feb 09 '22 10:02 Korijn

contributions to improve this will be highly regarded.

auvipy avatar Feb 10 '22 08:02 auvipy