我是RabbitMQ的新手,我一直在尝试关注RabbitMQ的tutorial。
我已经复制了send.php
和receive.php
的代码,但是当我运行send.php
和receive.php
脚本时,我收到以下错误:
Error Connecting to server(10061).: No connection could be made because the target machine actively refused it
我已禁用防火墙和所有防病毒程序,但我仍然遇到同样的错误。
send.php和receive.php的代码:
send.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
$msg = new AMQPMessage('Hello World!');
$channel->basic_publish($msg, '', 'hello');
echo " [x] Sent 'Hello World!'\n";
$channel->close();
$connection->close();
?>
receive.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
$channel = $connection->channel();
$channel->queue_declare('hello', false, false, false, false);
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";
$callback = function($msg) {
echo " [x] Received ", $msg->body, "\n";
};
$channel->basic_consume('hello', '', false, true, false, false, $callback);
while(count($channel->callbacks)) {
$channel->wait();
}
$channel->close();
$connection->close();
?>
有人可以帮我解决这个问题吗? 提前致谢
答案 0 :(得分:0)
正在搜索Error Connecting to server(10061)
我找到了this:
WSAECONNREFUSED(10061)
10061是服务器发送给您的连接被拒绝错误。您 无法建立连接,因为目标计算机是主动的 拒绝了。最常见的原因是服务器配置不正确, 完整服务器或客户端指定的错误端口。
上面链接的网站包含有关错误的更多信息以及可能导致您找到解决方案的可能原因列表。