Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sohelamin's avatar

Anyone used redis as queueing and broadcasting driver at same time?

Hi,

Any one used redis as broadcasting and queuing drive at the same time? I tried with both driver and it was not working it's only working if I choose redis for only one driver.

Eg:

QUEUE_DRIVER=redis
BROADCAST_DRIVER=redis

Even I've tried different redis connection in database configuration as below:

    'redis' => [

        'cluster' => false,

        'default' => [
            'host' => '127.0.0.1',
            'port' => 6379,
            'database' => 0,
        ],
        'pubsub' => [
            'host' => '127.0.0.1',
            'port' => 6380,
            'database' => 0,
        ],
    ],

Please let me help. Thanks

0 likes
8 replies
michaeldim's avatar

Are you getting any errors? Have you monitored the Redis connection in terminal to see what is being processed by the Redis server using 'redis-cli monitor' in command line.

How many Redis server instances do you have running, you can't just add another redis connection to your database config in Laravel and expect it to listen to a separate port on 6380 unless you have created another Redis instance and configured it to listen to a separate connection.

sohelamin's avatar

Yes I've tried with multiple redis instances eg: port 6379 & 6380 but no luck.

I ran 'redis-cli monitor' command and somehow laravel does not use multiple connection as I configured in database.php

sohelamin's avatar

Fixed it by instantiating new redis client with different connection. Eg:

$redis = Redis::connection('pubsub');

But it will be better if we could select the connection while broadcasting the event.

sohelamin's avatar

Actually I did the Redis things manually rather than depending on the event broadcasting. Like:

// Redis Publish
$redis = Redis::connection('pubsub');
$data = [
    'event' => 'App\\Events\\UserRegisteredEvent',
    'data' => [
        'name' => $user->name,
    ],
];
$redis->publish('user-register-channel', json_encode($data));

For now I need thing is done :)

I will find a better solution.

Please let me know if you get something.

Thanks

chuuke's avatar

Hey @Sohelamin, I am having a similar issue. I'm using redis as my broadcast driver, and watching for published events through socket.io. Everything is working fine in a local vm, however, when run on an EC2 production server, the publish event does not get fired when using ShouldBroadcast.

If I use the manual redis instantiation and publish snippet you did above, redis catches the publish event as it should, on both my local vm and production environments.

Any clues as to why Laravel cannot properly publish on an EC2 server setup almost identically to my local vm?

Thanks!

moren's avatar

worked for me with artisan queue:listen

muragijimana's avatar

The better solution is to set default driver which is not redis in services/queue.phpthen set another connection you wish to use using->onConnection('redis');

Please or to participate in this conversation.