It was working, but now it's not working anymore!
I'm using php-amqplib and RabbitMQ.
when I'm trying to create a new AMQP connection:
$connection = new AMQPConnection('localhost', 5672, 'username', 'password');
The code inside the library that is causing this error is:
public function read($n)
{
$res = '';
$read = 0;
while ($read < $n && !feof($this->sock) &&
(false !== ($buf = fread($this->sock, $n - $read)))) {
if ($buf === '') {
continue;
}
$read += strlen($buf);
$res .= $buf;
}
if (strlen($res)!=$n) {
throw new AMQPRuntimeException("Error reading data. Received " .
strlen($res) . " instead of expected $n bytes");
}
return $res;
}
When I put this just before the exception:
die($res." :".$n);
the result is:
Ï :7 :7
it is called twice, in first call $res is two null characters then "Ï"
and in second call it's just null.
oh and I deleted files inside mnesia folder of rabbitmq database manually once, I don't know if that caused the problem, but the RabbitMQ Management which is a web based app running on port 15672 is working fine.
I found the solution.
the user I was using didn't have access to the vhost, so in RabbitMQ Management I went to the admin tab and clicked on the username, and clicked on "set permission" button.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With