php - Trouble accessing a local process in another docker container -
i'm trying connect rabbitmq docker container php. error i'm getting uncaught exception 'errorexception' message 'stream_socket_client(): php_network_getaddresses: getaddrinfo failed: name or service not known'
. think issue how point program rabbitmq process.
the snippet of code think causing error
$connection = new amqpstreamconnection(getenv('message_broker_host'), 5672, 'guest', 'guest');
the environment variable i'm accessing defined in .env
message_broker_host=amqp://rabbitmq
i'm not used docker, under impression should work since process code runs on has rabbitmq linked in docker-compose file "rabbitmq".
the message_broker_host
env should rabbitmq
without amqp://
because phpamqp-lib not support dsns.
if you'd deal real dsn @ enqueue/amqp-lib.
the code like:
<?php use enqueue\amqplib\amqpconnectionfactory; $factory = new amqpconnectionfactory('amqp://guest:guest@rabbitmq:5672/%2f');
Comments
Post a Comment