1

When trying to access the rabbitmq from client side and it return 500 internal server error.

Here was the code to test the connection between client side and rabbitmq.

<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;

echo "Start here...";

$connection = new AMQPConnection('ip_adrress', 15672, 'guest', 'guest');

if ($connection->connect()){
        echo "Connected";
        $connection->close();
}
else{
        echo "Cannot connect";
}

echo "<br/>End here...";
?>

Here the error log. How to resolve the problem like this?

Error log :

PHP Fatal error: Uncaught exception 'PhpAmqpLib\Exception\AMQPRuntimeException' with message 'Error Connecting to server(13): Permission denied ' in /var/www/html/mydir/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:27\nStack trace:\n#0 /var/www/html/mydir/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Connection/AMQPStreamConnection.php(21): PhpAmqpLib\Wire\IO\StreamIO->__construct('ip adress', 15672, 3, 3, NULL)\n#1 /var/www/html/mydir/send.php(13): PhpAmqpLib\Connection\AMQPStreamConnection->__construct('ip address', 15672, 'guest', 'guest')\n#2 {main}\n thrown in /var/www/html/mydir/vendor/videlalvaro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php on line 27

4

1 回答 1

3

您似乎使用的15672是 RabbitMQ 管理 Web UI 端口,而不是用于 AMQP 连接的端口。尝试将其设置为5672

于 2015-04-13T21:22:04.800 回答