Asynchronous consumer on default exchange results in ACCESS_REFUSED

1,048 views
Skip to first unread message

Bálint Molnár

unread,
May 15, 2018, 11:56:22 AM5/15/18
to Pika
I'm trying to create an asynchronous consumer based on the this example provided by the documentation. It works well until you don't change the exchange to the default exchange (empty string and routing key None). In this case I'm constantly getting back Received remote Channel.Close (403): 'ACCESS_REFUSED - operation not permitted on the default exchange while if I try to connect to the same queue with a simple basic_consume there is no problem. (Note: if I 'skip' the declare parts and just simply bind same thing happens)
RabbitMQ 3.6.10, Erlang 19.3
Any ideas what am I missing?

lba...@pivotal.io

unread,
May 15, 2018, 12:04:16 PM5/15/18
to Pika
Hi Bálint,

Why are you using None for a routing key? Since the default exchange is a direct exchange, it doesn't make any sense to not use a routing key. This is why RabbitMQ is closing the channel with the error you provide.


Thanks,
Luke

Bálint Molnár

unread,
May 15, 2018, 12:11:04 PM5/15/18
to pika-...@googlegroups.com
Hi,

What I did is simply removed the routing key for the binding process, and if you check (any of) the signature of the Channle.queue_bind the routing_key is defaulted to None, this is how I meat setting it to None.

Regards,
Balint


--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

lba...@pivotal.io

unread,
May 15, 2018, 12:19:02 PM5/15/18
to Pika
Hi Bálint -

Binding to a direct exchange requires a valid routing key. routing_key defaults to None as that can be a valid value for other exchange types, just not a direct exchange.

So, I recommend using a valid routing key when binding to a direct exchange which will resolve your issue.

Luke

On Tuesday, May 15, 2018 at 9:11:04 AM UTC-7, Bálint Molnár wrote:
Hi,

What I did is simply removed the routing key for the binding process, and if you check (any of) the signature of the Channle.queue_bind the routing_key is defaulted to None, this is how I meat setting it to None.

Regards,
Balint

2018-05-15 18:04 GMT+02:00 <lba...@pivotal.io>:
Hi Bálint,

Why are you using None for a routing key? Since the default exchange is a direct exchange, it doesn't make any sense to not use a routing key. This is why RabbitMQ is closing the channel with the error you provide.


Thanks,
Luke

On Tuesday, May 15, 2018 at 8:56:22 AM UTC-7, Bálint Molnár wrote:
I'm trying to create an asynchronous consumer based on the this example provided by the documentation. It works well until you don't change the exchange to the default exchange (empty string and routing key None). In this case I'm constantly getting back Received remote Channel.Close (403): 'ACCESS_REFUSED - operation not permitted on the default exchange while if I try to connect to the same queue with a simple basic_consume there is no problem. (Note: if I 'skip' the declare parts and just simply bind same thing happens)
RabbitMQ 3.6.10, Erlang 19.3
Any ideas what am I missing?

--
You received this message because you are subscribed to the Google Groups "Pika" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pika-python...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Bálint Molnár

unread,
May 15, 2018, 12:30:25 PM5/15/18
to pika-...@googlegroups.com
Hi Luke,

When checking the Channel.queue_bind there is this:
        if routing_key is None:
            routing_key = queue
This will always resolve in a valid routing key which is the queue name, this is a valid for the default exchange I presume.

Regards,
Balint



To unsubscribe from this group and stop receiving emails from it, send an email to pika-python+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Bálint Molnár

unread,
May 15, 2018, 1:38:32 PM5/15/18
to pika-...@googlegroups.com
Hi,

Just to close the issue I found the solution.
The default exchange is bound automatically to the queue - as mentioned in the RabbitMQ documentation. The problem originates - as I understand - that re-binding/binding it is not allowed - since it is already bound - for the default exchange.
So in case when the the exchange is the default exchange the following line needs to be skipped.
self._channel.queue_bind(self.on_bindok, self.QUEUE, self.EXCHANGE, self.ROUTING_KEY)
(Also deceleration for the default exchange is not  required, which also can be to be skipped)

Regads,
Balint
Reply all
Reply to author
Forward
0 new messages