2

I have a RabbitMQ container and a PHP 7 container with a Symfony 3.1.x project that executes a RabbitMQ consumer using the OldSoundRabbitMqBundle.

When running this command that executes the test consumer:

bin/console rabbitmq:consumer -w test

I get the following error:

[PhpAmqpLib\Exception\AMQPIOException]

Error reading data. Received 0 instead of expected 7 bytes

My setup is very simple and I checked the following things:

  • RabbitMQ is at its latest version (3.6.5)
  • The configured host, vhost, user, password parameters are correct
  • mbstring extension is enabled

It's really easy to set up a project to reproduce the issue.

The sample project is available on GitHub and instructions are provided in the README file to reproduce the issue with just a few steps.

Here are some highlights:

docker-compose.yml

version: '2'
services:
  php:
    build: ./docker/php/
    links:
      - rabbitmq
    volumes:
      - ./src:/var/www/rabbitmq-test
    working_dir: /var/www/rabbitmq-test

  rabbitmq:
    image: rabbitmq:3.6-management

config.yml

old_sound_rabbit_mq:
    connections:
        default:
            host:     'rabbitmq'
            port:     5672
            user:     'guest'
            password: 'guest'
            vhost:    '/'
            lazy:     false
            # ...
    producers:
        # ...
    consumers:
        test:
            connection:       default
            exchange_options: {name: 'test', type: direct}
            queue_options:    {name: 'test'}
            callback:         test_consumer

The test_consumer service is a very simple class implementing the ConsumerInterface interface.

Would someone have any idea concerning my problem?

7
  • This happen without any pending message? Commented Sep 22, 2016 at 14:22
  • @Yonel Yes, it happens even without any pending message. I don't see any error on the RabbitMQ side. Commented Sep 22, 2016 at 14:24
  • The exception comes from SocketIO.php or StreamIO.php ? Commented Sep 22, 2016 at 14:47
  • What do you do in test_consumer ? Commented Sep 22, 2016 at 14:49
  • @Yonel The exception comes from SocketIO.php. Commented Sep 22, 2016 at 14:49

1 Answer 1

3

The answer was really straightforward. I had to change this in my config.yml:

old_sound_rabbit_mq:
    connections:
        default:
            # ...

            use_socket: true

to:

old_sound_rabbit_mq:
    connections:
        default:
            # ...

            use_socket: false

Note that false is the default value.

Sign up to request clarification or add additional context in comments.

3 Comments

Great! from this parameter depends the connection factory class used for new connections (+1)
Yes, exactly. Thanks for your help @Yonel .
Works like a charm without socket!, but how can make it working with sockets ? I already installed sockets extension for php but even did not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.