rabbitmq / rabbitmq-auth-backend-http

HTTP-based authorisation and authentication for RabbitMQ
Other
199 stars 72 forks source link

auth/topic endpoint called twice #72

Closed rozaydin closed 6 years ago

rozaydin commented 6 years ago

Hello,

We are using the auth-backend-http along with mqtt plugin, everything is working fine, but we realized one thing. Whenever we sent an MQTT "Subscribe" or "Publish" the auth-backend-http is sending request to /auth/topic endpoint twice with same contents. Is there a specific reason why its doing this ?

You can find a wireshark capture from the machine, and a screenshot attached.

duplicate

duplicate-msgs-pcap.zip

Thanks is advance

michaelklishin commented 6 years ago

I don't think it's intentional but without a way to reproduce I would rather not speculate. Can you provide a way to reproduce?

Also, in practice this plugin is used together with rabbitmq-auth-backend-cache which masks this behavior entirely.

lukebakken commented 6 years ago

I can reproduce this and am investigating why.

michaelklishin commented 6 years ago

@rozaydin our working theory is that the MQTT plugin performs at least two operations when you begin consuming since it has to check for queue existence (and thus establish whether there's an existing session state). In that case it is expected that two authorization checks are performed.

lukebakken commented 6 years ago

@michaelklishin @rozaydin - yep, that is what is happening. This is the code that executes for a new subscription. Notice here that topic authorization is checked, and then the queue is declared and consumed from here, which will cause another check. I've attached a trace here:

trace.txt

Please use the cache backend to "resolve" this issue. Thanks!

rozaydin commented 6 years ago

Hi @michaelklishin @lukebakken, Thanks a lot for the clarification. Knowing that why it is behaving this way is a lot better. (I will enable the cache plugin as well)