【发布时间】:2014-08-10 07:47:30
【问题描述】:
它可以工作,但现在它不再工作了!
我正在使用 php-amqplib 和 RabbitMQ。
当我尝试创建新的 AMQP 连接时:
$connection = new AMQPConnection('localhost', 5672, 'username', 'password');
库中导致此错误的代码是:
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;
}
当我把它放在异常之前:
die($res." :".$n);
结果是:
Ï :7 :7
它被调用了两次,第一次调用 $res 是两个空字符,然后是 "Ï"
在第二次调用中它只是空值。
哦,我曾经手动删除了rabbitmq数据库的mnesia文件夹中的文件,我不知道这是否导致了问题,但是在端口15672上运行的基于Web的应用程序RabbitMQ管理工作正常。
【问题讨论】: