PHP client cannot connect to RabbitMQ server on localhost

OS : CentOS 6.4
I am trying to connect to the RabitMQ server using the php client as follows:

$connection = new AMQPConnection('10.1.150.109', 5672, 'guest', 'guest');
$channel = $connection->channel();

But when I run the script from the browser, it gives me this, an
exception "PhpAmqpLib \ Exception \ AMQPRuntimeException" with the message "Server connection error (13): Permission denied" in / var / www / html / event / vendor / videlalvaro / php -amqplib / PhpAmqpLib / Wire / IO / StreamIO.php: 27

netstat show this,
  tcp 0 0: 5672: * LISTEN 10776 / beam

In this message this guy gives an implicit answer, the Client cannot connect to the RabbitMQ server on localhost . But he did not describe the procedure that he was doing to fix this problem.

I thank you for the promotion for those who can help me in this regard.

+4
source share
2 answers

what happens if you

 telnet 10.1.150.109 5672
+1
source

Since I don’t like the accepted answer, here I think it’s better.

Disabling SELinux is a hack. It might work, but it is probably not a good idea. What is not immediately apparent from the question (or another question to which it refers) is HOW the php client starts. That is, from the command line or through a browser.

SELinux will by default prevent httpd (e.g. apache) from connecting to port 5672.

In my case, running php script from the command line works - the connection is accepted. However, launching from the browser is not performed due to this SELinux policy.

, " 0.0.0.0 127.0.0.1" , "localhost", IP-. ( 0.0.0.0 !)

httpd 5672 SELinux: https://serverfault.com/questions/563872/selinux-allow-httpd-to-connect-to-a-specific-port

+6

Source: https://habr.com/ru/post/1527310/


All Articles