Unable to connect to RabbitMQ: Error reading data. Received instead of expected 7 bytes

646 views
Skip to first unread message

Lekan Wahab

unread,
May 20, 2016, 12:44:11 PM5/20/16
to rabbitmq-users

I have a problem connecting to the rabbitmq php-amqplib client. I keep getting the error "Unable to connect to RabbitMQ: Error reading data. Received instead of expected 7 bytes". I have read but then i couldnt find i definite solution to the issue. I also read but still havent figured out whats wrong.

Here is my code and the error.


Connector.php


public static function RabbitMQ()
    {
        static $instances;

        if (!isset ($instances))    $instances = array ();
        if (empty($instances['rabbitMQ'])) {
            $rabbitMQ = null;
            $_ci =& get_instance();
            $_rabbit_config = $_ci->config->item('rabbitmq');

            try {
                $rabbitMQ = new \PhpAmqpLib\Connection\AMQPConnection(
                    $_rabbit_config['host'],
                    $_rabbit_config['port'],
                    $_rabbit_config['username'],
                    $_rabbit_config['password']);
                $rabbitMQ = $rabbitMQ->channel();
            }
            catch (Exception $e) {
                show_error("Unable to connect to RabbitMQ: {$e->getMessage()}", 500);
            }
            $instances['rabbitMQ'] = $rabbitMQ;
        }
        return $instances['rabbitMQ'];




rabbitmq.php (Rabbitmq client config)

$config["rabbitmq"] = array("host"=>"127.0.0.1", "port"=>"5672", "username"=>"guest", "password"=>"guest"); $config["rabbitmq-queue"] = array( "kannel-request" => "soccer-trivial-request", "registration-queue" => "soccer-trivial-registration" );



browsererror1.png
browsererror2.png

Michael Klishin

unread,
May 20, 2016, 2:44:46 PM5/20/16
to rabbitm...@googlegroups.com
What port is actually used? What's in RabbitMQ logs?
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<browsererror1.png>
<browsererror2.png>
Reply all
Reply to author
Forward
0 new messages