5

I am new to RabbitMQ and I've been trying to follow the tutorial of RabbitMQ.

I've copied the code for send.php and receive.php, but when I run the send.php and receive.php scripts, I get the following error:

Error Connecting to server(10061).: No connection could be made because the target machine actively refused it

I've disabled my firewall and all my anti-virus programs, but I still get the same error.

The code of send.php and 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();

?>

Can someone help me with this problem? Thanks in advance

lcsvcn
  • 1,184
  • 3
  • 13
  • 28
Jan368
  • 51
  • 1
  • 2
  • Did you test if the port 5672 isn't being used already? – lcsvcn Oct 27 '14 at 14:59
  • I tested it, following this answer: http://stackoverflow.com/questions/273159/how-to-determine-if-a-port-is-open-on-a-windows-server. So when I executed the command "telnet localhost 5672", i couldn't make a connection. So I assume that port is still available right? I also tried to change the portnumber in de php-files but I still get the same error as before. – Jan368 Oct 27 '14 at 15:14

0 Answers0