它工作,但现在它不再工作了!
我正在使用php-amqplib和RabbitMQ.
当我尝试创建新的AMQP连接时:
$connection = new AMQPConnection('localhost', 5672, 'username', 'password');
Run Code Online (Sandbox Code Playgroud)
导致此错误的库中的代码是:
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;
}
Run Code Online (Sandbox Code Playgroud)
当我把它放在异常之前:
die($res." :".$n);
Run Code Online (Sandbox Code Playgroud)
结果是:
Ï :7 …Run Code Online (Sandbox Code Playgroud)