rabbitmq 无法通过Docker容器连接到AMQP服务器

mtb9vblg  于 2022-11-08  发布在  RabbitMQ
关注(0)|答案(1)|浏览(245)

我试图在我的Dockerized Symfony应用程序中使用Messenger和AMQP传输。当我在处理程序中调度消息时,我收到以下错误:

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

.环境:

MESSENGER_TRANSPORT_DSN=amqp://guest:guest@rabbitmq:5672/%2f/messages
cl25kdpy

cl25kdpy1#

将环境变量更改为

MESSENGER_TRANSPORT_DSN=amqp://guest:guest@host.docker.internal:5672/%2f/messages

看起来很有效

相关问题