Naoki Peter
Naoki Peter

Reputation: 71

Laradock: Laravel queue worker can't connect to RabbitMQ

I've set up a Laravel (5.6) application with RabbitMQ (3.7.6) using the latest Laradock and composer-installed https://github.com/vyuldashev/laravel-queue-rabbitmq . When I start the Laravel message worker with php artisan queue:work I'm getting the following error

local.ERROR: AMQP error while attempting pop: stream_socket_client(): 
unable to connect to tcp://127.0.0.1:5672 (Connection refused)  

However, I can connect to Rabbit using telnet 127.0.0.1 5672 (the connection is closed after 10 seconds of inactivity). The listeners seem to be working correctly:

{listeners,[{clustering,25672,"::"},{amqp,5672,"::"},{http,15672,"::"}]}

I've also checked the RabbitMQ logs, but nothing shows up there. So I assume it's a problem on the client side but I'm not sure where to look.

RabbitMQ settings in Laravel .env

QUEUE_DRIVER=rabbitmq
RABBITMQ_QUEUE=default
RABBITMQ_DSN=amqp:

Laradock .env

RABBITMQ_NODE_HOST_PORT=5672
RABBITMQ_MANAGEMENT_HTTP_HOST_PORT=15672
RABBITMQ_MANAGEMENT_HTTPS_HOST_PORT=15671
RABBITMQ_DEFAULT_USER=guest
RABBITMQ_DEFAULT_PASS=guest

Any ideas?

Upvotes: 0

Views: 2815

Answers (1)

Naoki Peter
Naoki Peter

Reputation: 71

I was missing the implements ShouldQueue on the line with the class definition of my Notification class. Also, I had to build php-worker with bcadd and mongodb extensions.

RUN pecl install mongodb && docker-php-ext-enable mongodb
RUN docker-php-ext-install mysqli mbstring pdo pdo_mysql tokenizer xml pcntl bcmath

Upvotes: 1

Related Questions