Reputation: 13
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
Upvotes: 1
Views: 3885
Reputation: 2313
You seem to be using the port 15672
which is the RabbitMQ Management Web UI port, but not the port used for AMQP connections. Try setting it to 5672
Upvotes: 3