php-amqplib: Uncaught exception ‘Exception’ with message ‘Error reading data. Recevived 0 instead of expected 1 bytes’May 1st, 2012
I’ve been playing around with RabbitMQ recently, but trying to find out what caused the above error included a trip through wireshark and an attempt to dig through the source code of php-amqplib. It seems that it’s (usually) caused by a permission problem: either the wrong username / password combination as reported by some on the wide internet, or by my own issue: the authenticated user didn’t have access to the vhost I tried to associate my connection with.
You can see the active permissions for a vhost path by using rabbitmqctl:
sudo rabbitmqctl list_permissions -p /vhostname
.. or you if you’ve installed the web management plugin for rabbitmq: select Virtual Hosts in the menu, then select the vhost you want to see permissions for.
You can give a user (all out) access to the vhost by using rabbitmqctl:
sudo rabbitmqctl set_permissions -p /vhostname guest ".*" ".*" ".*"
.. or by adding the permissions through the web management interface, where you can select the user and the permission regexes for the user/vhost combination.