https://github.com/laravel/laravel/blob/da83285/config/database.php#L126 this config/database.php Redis prefix line, is a hard-code un-customizable prefix (not in .env at least), to set a for all Redis connections.
But the heavy serious question is, it will add prefix named laravel_database_ before your channel name when you trigger an web socket event from laravel application, into laravel_database_private.channel.xxx.

Reference
this config/database.php redis prefix line, is a hardcode logic to set a un-customizable prefix for all redis connections.
You can change that prefix to be anything you want. You control that code.
I think the apparent bug is that, if a prefix is set, it is not appended to the channel name? Is that a bug in Laravel Framework, or a bug in Laravel Echo?
this config/database.php redis prefix line, is a hardcode logic to set a un-customizable prefix for all redis connections.
You can change that prefix to be anything you want. You control that code.
I think the apparent bug is that, if a prefix is set, it is not appended to the channel name? Is that a bug in Laravel Framework, or a bug in Laravel Echo?
Yep, laravel-echo client does not support to set a string prefix for channel name.
// the private method will add, and only add `private-` prefix,
// which mismatch with laravel 5.8 redis driver provides `laravel_database_private-`.
echo.private(`chat.${room_id}`).listen()
I suggest to remove config/database.php's redis.options.prefix option, because in the mix multiple laravel redis structure, better to set different redis database name REDIS_DB / REDIS_CACHE_DB for every app
This is the same issue as https://github.com/laravel/echo/issues/232
I'd say this is a framework issue so we should try to see to strip the prefix before emiting back to echo.
I was trying to debug this but I'm currently stuck with setting up laravel-echo-server. If anyone could help out so I can debug this issue further, that'd be nice: https://github.com/tlaverdure/laravel-echo-server/issues/428
Managed to get it to work. @xiaohuilam I managed to reproduce the issue.
I spent quite some time debugging this. The event gets published to Redis here: https://github.com/laravel/framework/blob/24cc1786bd55876fa52380306354772355345efd/src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php#L102
Until this point everything's okay. But the channel probably gets its prefix set as soon as its published on this line. I can't figure out where the event gets pulled out of Redis. I suspect somewhere in Socket.io but I can't find it. And thus I can't figure out a way to strip the prefix again.
If anyone is willing to put in work into this that'd be great.
[..] is a hard-code un-customizable prefix (not in .env at least), to set a for all Redis connections.
This is now customisable out of the box with the REDIS_PREFIX variable.
[..] is a hard-code un-customizable prefix (not in .env at least), to set a for all Redis connections.
This is now customisable out of the box with the
REDIS_PREFIXvariable.
Better to default empty in .env.example (Existing project won't override the .env by copy .env.example).
Dont work REDIS_PREFIX="" in .env for fix prefix
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
// 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
],
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
Dont work private channels then comment 'prefix' or 'prefix' => "" or 'prefix => " "
This is now fixed thanks to @tlaverdure in https://github.com/laravel/framework/pull/30597
This is now fixed thanks to @tlaverdure in #30597
Unfortunately, it didn't fix. Authorization in private channels works fine, but messages still sending in the wrong channel, using the prefix in the channel name.

Have you upgraded to the latest version of Laravel Echo Server (1.6.0)?
@tlaverdure there's no such release? https://github.com/tlaverdure/laravel-echo-server/releases
Oops, published to npm but forgot to update the repo.
This solved the problem (https://github.com/tlaverdure/laravel-echo-server/releases/tag/1.6.0):
{
"databaseConfig": {
"redis": {
"keyPrefix": "laravel_database_"
}
}
}
@tlaverdure and @driesvints Thank you very much!
Thanks
how can I get key prefix directly from the env file
Most helpful comment
This solved the problem (https://github.com/tlaverdure/laravel-echo-server/releases/tag/1.6.0):
@tlaverdure and @driesvints Thank you very much!