-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config/database.php redis prefix question #28701
Comments
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 |
This is the same issue as laravel/echo#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: tlaverdure/laravel-echo-server#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:
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. |
This is now customisable out of the box with the |
Better to default empty in |
Dont work REDIS_PREFIX="" in .env for fix prefix #database.php
Dont work private channels then comment 'prefix' or 'prefix' => "" or 'prefix => " " |
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 |
Description:
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, intolaravel_database_private.channel.xxx
.Reference
The text was updated successfully, but these errors were encountered: