D
D
dieselbox2013-07-23 18:00:20
PHP
dieselbox, 2013-07-23 18:00:20

Can't connect to RabbitMQ in PHP

The essence of the problem: when connecting to the Rabbit server, the script throws out an error:
php: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/amqp.so: undefined symbol: amqp_open_socket

The library file is present /usr/local/lib/php/extensions/no-debug-non-zts-20090626/amqp.so. The librabbitmq library is installed on the system.

Code that triggers the error:

    try
    {
      $Connection = new AMQPConnection();
      $Connection->setLogin('login');
      $Connection->setPassword('password');
      $Connection->setVhost('host');
      $Connection->setHost('localhost');
      $Connection->setPort(5672);
      $Connection->connect();
    }
    catch (\Exception $e)
    {
      echo 'Ошибка: ' . $e->getMessage();
    }


Searching for the corresponding function in the library binary yields:
$ nm -D /usr/local/lib/php/extensions/no-debug-non-zts-20090626/amqp.so | fgrep amqp_open_socket
                 U amqp_open_socket


The Rabbit server itself is running on port 5672:
$ sudo netstat -anlp | grep 5672
tcp        0      0 127.0.0.1:5672          0.0.0.0:*               LISTEN      16772/beam.smp


The amqp extension (for working with the Rabbit server in php) is installed via PECL:
$ php -c /usr/local/var/run/php.ini -m
[PHP Modules]
amqp
Core
ctype
curl
date
dom
ereg
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mysql
mysqlnd
pcntl
pcre
PDO
pdo_cubrid
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
shmop
SimpleXML
soap
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib


Software versions:
PHP 5.4.16
amqp 1.2.0
AMQP protocol version 0-9-1
librabbitmq version 0.3.0

Who can tell me what could be the solutions to the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zarincheg, 2013-07-23
@zarincheg

I also had some problems with RabbitMQ, they solved it by installing this library github.com/alanxz/rabbitmq-c instead of librabbitmq, which is in the ubunta repository. And it seems that you need to rebuild / reinstall the PHP extension.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question