I'm invoking nameko shell
inside my docker container of the example service, but I receive this error. I have setup two containers. My rabbitmq container and my service container. I'm invoking the nameko shell
from inside the service container bash. The containers start up correctly and the service container connects successfully. But I can't use the shell.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 138, in _connect
host, port, family, socket.SOCK_STREAM, SOL_TCP)
File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -9] Address family for hostname not supported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/nameko", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/nameko/cli/main.py", line 112, in main
args.main(args)
File "/usr/local/lib/python3.6/site-packages/nameko/cli/commands.py", line 143, in main
main(args)
File "/usr/local/lib/python3.6/site-packages/nameko/cli/shell.py", line 98, in main
ctx['n'] = make_nameko_helper(config)
File "/usr/local/lib/python3.6/site-packages/nameko/cli/shell.py", line 73, in make_nameko_helper
module.rpc = proxy.start()
File "/usr/local/lib/python3.6/site-packages/nameko/standalone/rpc.py", line 228, in start
self._reply_listener.setup()
File "/usr/local/lib/python3.6/site-packages/nameko/rpc.py", line 260, in setup
self.queue_consumer.register_provider(self)
File "/usr/local/lib/python3.6/site-packages/nameko/standalone/rpc.py", line 123, in register_provider
self._setup_consumer()
File "/usr/local/lib/python3.6/site-packages/nameko/standalone/rpc.py", line 102, in _setup_consumer
channel = self.connection.channel()
File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 289, in channel
chan = self.transport.create_channel(self.connection)
File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 867, in connection
max_retries=1, reraise_as_library_errors=False
File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 445, in _ensure_connection
callback, timeout=timeout
File "/usr/local/lib/python3.6/site-packages/kombu/utils/functional.py", line 344, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 874, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.6/site-packages/kombu/connection.py", line 809, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.6/site-packages/kombu/transport/pyamqp.py", line 130, in establish_connection
conn.connect()
File "/usr/local/lib/python3.6/site-packages/amqp/connection.py", line 314, in connect
self.transport.connect()
File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 78, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 149, in _connect
"failed to resolve broker hostname"))
File "/usr/local/lib/python3.6/site-packages/amqp/transport.py", line 162, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
FROM python:3-onbuild
CMD ["nameko", "run", "--config", "conf.yml", "helloworld"]
AMQP_URI: 'pyamqp://guest:guest@rabbitmq'
version: '2'
services:
echo:
build: ./echo
restart: always
volumes:
- .:/echo/code
depends_on:
- rabbitmq
rabbitmq:
image: "rabbitmq"
ports:
- "15673:15672"
I found out after a while that it was my own stupid mistake. I forgot to add the config file in my nameko shell
command. You have to specify the message broker when executing nameko shell. In my case I needed to run nameko shell --config config.yml
. That enabled me to connect and test my nameko service.