0
votes

I have three docker containers:

  • rabbitmq (with management plugin enabled)
  • consumer (multithreaded python application using pika)
  • producer (multithreaded python application using pika)

Both consumer and producer are able to connect to the rabbitmq queue, but messages sent from the producer never reach the consumer. Actually, they are not even seen on the rabbitmq instance (I have verified this via the management interface)

I have tried lots of different combinations to connect to the rabbitmq docker instance: 0.0.0.0 network, 172.17.x.x network, ... Currently I am using amqp://guest:[email protected]:5672, which is working (I am able to open a connection), but does not allow sending messages.

From the host I must use http://0.0.0.0:55673 to connect to the management interface (55673 being the mapped management port)

The same configuration without docker is working fine: rabbitmq running as host service (or even in the cloud), and my consumer/producer as plain processes. Connection is fine, and messages are delivered.

What could be the reason why the connection is being opened just fine, but messages are not delivered when using docker?

What tests could I perform to further narrow the problem?

EDIT

The rabbitmq consumer shows the following in the log:

=INFO REPORT==== 11-May-2016::14:25:54 ===
accepting AMQP connection <0.687.0> (172.17.0.3:53576 -> 172.17.0.2:5672)

=INFO REPORT==== 11-May-2016::14:26:06 ===
accepting AMQP connection <0.825.0> (172.17.0.4:48607 -> 172.17.0.2:5672)

The other containers have an empty log

EDIT2

This is how I run the rabbitmq container:

docker run -d -p 5672:5672 -p 55673:15672 --hostname my-rabbit --name rabbitmq rabbitmq:3.6.1-management

EDIT3

Same effect when connecting containers to a custom bridge:

docker network create -d bridge mynet
docker run --net mynet --name rabbitmq ...
docker run --net mynet --name consumer ...
docker run --net mynet --name producer ...

Hosts can ping each other by name (using the DNS provided by the docker daemon), and I can thus use the hostname to connect to the RabbitMq server.

The connection is established but the messages are not delivered.

Very strange, since the ping packets are reaching the other container just fine.

2
Can you post docker logs of the 3 containers?user2915097
@user2915097: added!blueFast
Are the containers "based" on the official rabbitmq image?cantSleepNow
@cantSleepNow: The rabbitmq container is an instantiation of rabbitmq:3.6.1-management. The consumer and producer are based on python:3-onbuildblueFast
I think that that image is made with guest user having access outside of localhost, but maybe check that...cantSleepNow

2 Answers

0
votes

My code had a bug: the routing_key was wrongly set in the producer, that's why the messages were not being delivered to the right queue.

I was completely confused because this bug did not surface when using barebones rabbitmq (without docker)

0
votes

In case the routing key is not correct, then there is no error from RMQ, to prevent this, we can use queuedeclarePassive before publishing a message.