我已经编写了一个函数来检查rabbitmq是否正在运行。
function getBrokerStatus()
{
log_message("info", "Checking if broker is running....");
try {
$amqpConnection = new AMQPConnection();
$amqpConnection->setLogin("guest");
$amqpConnection->setPassword("guest");
$amqpConnection->setVhost("/");
$amqpConnection->connect();
} catch (Exception $e) {
log_message("info", "Exception: " . $e->getMessage());
return false;
}
if (!$amqpConnection->isConnected()) {
log_message("info", "Cannot connect to the broker! It might not be running");
return false;
}
$amqpConnection->disconnect();
return true;
}我的代码捕捉到了这个异常。我在下面的日志中看到-
Exception: Socket error: could not connect to host.但是我的rabbitmq服务器正在运行,为什么我会得到这个异常?我正在使用rabbitmq- v3.1.1的服务器。
发布于 2014-10-16 15:52:44
如果你不能在你的机器上ping你的本地主机,那一定是你没有设置你的主机文件。在/etc/hosts中编辑它
https://stackoverflow.com/questions/22247271
复制相似问题