Reputation: 620
I've just setup a RabbitMQ Docker container to use with a Symfony 5.2 application. But I'm having troubles with auto-exposed env vars from Docker.
As the RabbitMQ container is up and running fine, I'm waiting for a RABBITMQ_DSN
env var automatically set by Symfony.
The weird behaviour is sometimes I do get this env var but sometimes I don't (on the same request !).
I also get the same behaviour when dumping my env vars (I sware there are no changes between the 2 commands...) :
$ APP_ENV=dev symfony var:export --multiline | grep 'RABBITMQ'
export RABBITMQ_DSN=amqp://guest:[email protected]:49167
export RABBITMQ_HOST=127.0.0.1
export RABBITMQ_MANAGEMENT_HOST=127.0.0.1
export RABBITMQ_MANAGEMENT_IP=127.0.0.1
export RABBITMQ_MANAGEMENT_PORT=49168
export RABBITMQ_MANAGEMENT_SCHEME=http
export RABBITMQ_MANAGEMENT_SERVER=http://127.0.0.1:49168
export RABBITMQ_MANAGEMENT_URL=http://127.0.0.1:49168
export RABBITMQ_PASSWORD=guest
export RABBITMQ_PORT=49167
export RABBITMQ_SCHEME=amqp
export RABBITMQ_SERVER=amqp://127.0.0.1:49167
export RABBITMQ_URL=amqp://guest:[email protected]:49167
export RABBITMQ_USER=guest
export RABBITMQ_USERNAME=guest
$ APP_ENV=dev symfony var:export --multiline | grep 'RABBITMQ'
export RABBITMQ_HOST=127.0.0.1
export RABBITMQ_IP=127.0.0.1
export RABBITMQ_PORT=49168
I' tried several things :
But I'm still stuck with this bug... I'm running this app on Windows 10.
Any idea ?
Upvotes: 1
Views: 2416
Reputation: 620
Ok,
I found a workaround by using another env var that I setup explicitly in my .env
file.
I can't figure out why this RABBITMQ_DSN
env var is sometimes missing.
Here is the workaround.
Just set up a new env var in .env
file :
MESSENGER_TRANSPORT_DSN=amqp://guest:[email protected]:49167
And use it instead of the missing RABBITMQ_DSN
in your messenger.yml
file :
framework:
messenger:
transports:
async:
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
Upvotes: 2