I'm setting up Laravel echo to broadcast events. But whenever I try to broadcast to a channel the channel name gets an automatic prefix: 'laravel_database_'
I've tried switching the return inside the Event to a regular 'Chanel' as following:
public function broadcastOn()
{
return new Channel('public');
}
but when I look into the laravel-echo-server logs I see it is still being broadcasted on: 'laravel_database_public'.
This way I would need to do the following in my JS:
Echo.channel('laravel_database_public').listen('MessageSent', ({message}) => {
console.log(message);
});
But ofcourse, I want to remove the prefix (or figure out why its there). Hopefully someone can clear this up for me. Thanks in advance.
This is configurable in config/database.php
(and I believe even removable) under
'redis' => [
'options' => [
'prefix' => // change here.
]
]
The accepted answer does not work with laravel-echo-server.
The solution is rather to let the whole Redis Laravel config untouched and to run version ^1.6.0
of laravel-echo-server with the proper keyPrefix
option in laravel-echo-server.json
config file:
{
"databaseConfig": {
"redis": {
"keyPrefix": "laravel_database_"
}
}
}
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With