Home > OS >  Could not connect to the AMQP server via Docker container
Could not connect to the AMQP server via Docker container

Time:10-15

I am trying to use Messenger with the AMQP Transport within my Dockerized Symfony application. When I dispatch a message in the handler, I get the following error:

In AmqpReceiver.php line 62:

  [Symfony\Component\Messenger\Exception\TransportException]
  Could not connect to the AMQP server. Please verify the provided DSN.

messenger.yaml:

framework:
    messenger:
        transports:
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'

        routing:
            # Route your messages to the transports
            'App\Message\MyCustomRequest': async

docker-compose.yml:

  rabbitmq:
    image: rabbitmq:3.8-management
    environment:
      RABBITMQ_DEFAULT_USER: guest
      RABBITMQ_DEFAULT_PASS: guest
    ports:
      - 5671:5672
      - 15671:15672

.env:

MESSENGER_TRANSPORT_DSN=amqp://guest:guest@rabbitmq:5672///messages

CodePudding user response:

Changing the environment variable to

MESSENGER_TRANSPORT_DSN=amqp://guest:[email protected]:5672///messages

Seems to do the trick

  • Related