-
Notifications
You must be signed in to change notification settings - Fork 185
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
Redis keyPrefix Problem #232
Comments
It can be fixed by below steps. Broadcast::channel('foo_bar_database_private-test', function ($user) {
return true;
}); 3-) At the frontend part, register your channels as follows Echo.private(`foo_bar_database_private-test`)
.listen('.user.registered',function (e) {
console.log(e);
}); 4-) Broadcast event and see console output for laravel-echo-server
5-) As you can see, the channel names match. To solve this bug, Private("private-") and Presence("presence-") prefixes should not be mandatory. |
Do you actually need the Redis prefix in this situation? |
Same problem here. Echo.private will add a prefix private- to channel's name. So Laravel adds laravel_database_private-channel prefix and Echo.private(laravel_database_private-channel) will add another prefix like so: private- laravel_database_private-channel And Echo will not get the event never becouse it's listening on other channel. |
I was able to get it working: In config/database.php disable prefix for redis. Now i can do
And in routes/channels.php
With redis-cli monitor 👍
And Echo clients gets their message. |
Actually i do, because i have a server with multiple websites. The keys may conflict. |
We probably don't want to fiddle too much with the internals with Echo. Is there some way we can strip the redis prefix again when fetching the events? Trying to think out loud here. |
Closing this since this is more of a framework issue than echo. Let's continue the discussion here: laravel/framework#28701 |
I know this is closed but I disagree that this is a framework issue. The echo server should be configurable such that if there is a prefix it can be prepended to the names of the keys. If this is how Laravel writes to redis, why should this not support that prefix? It tends to default to |
This is definitely a |
const echo = new Echo({
// ...
keyPrefix: "laravel_database_"
}); What do you think? |
@eightyfive laravel echo server has introduced a prefix by now: laravel/framework#28701 (comment) |
@driesvints Indeed and echo server does broadcast the event with the keyPrefix. So nothing wrong here. Problem is echo Client no picking up that prefixed event: laravel_database_private-App... I’m pretty sure I am not mistaken cause when I remove the keyPrefix everywhere (Laravel & echo server), echo client works fine. So it’s pretty clear it does not listen to the keyPrefixed event name. Let me know, thanks. |
@eightyfive can you verify with laravel-echo-server that this never worked on their side and report back? Thanks! |
same issue, keyPrefix in echo options needed =( |
Hey all, This has been fixed in Turns out the Redis Broadcaster was ignoring the My bad pointing out the problem might come from |
@eightyfive Laravel still has this issue BTW. I just created a fresh Laravel app and tested this. confirmed it is still broadcasting the database redis prefix |
@eightyfive I found the solution. On your larave-echo-server.json file
On your js files
|
Problem was caused by [6.x] Fix channel names when broadcasting via redis, not by |
As you're using Laravel just edit your .env file and set:
This will remove the 'foo_bar_database_' prefix from your channel names. Then make sure you've restarted your services. |
so
|
Description:
When Echo used with Redis, it produces keyPrefix to every channel you created. (which is by default "laravel_database_")
Steps To Reproduce:
1-) Use Redis as Broadcast Driver and Queue Connection
2-) Create any Event
3-) Broadcast this event with Private Channel called 'test'
4-) Authorize this channel
5-) Initialize Echo in your js file
6-) Initialize your channel
7-) Send event
8-) See laravel-echo-server logs
My Redis keyPrefix is "foo_bar_database_", so the channel name that the event emitted is "foo_bar_database_private-test" but i am listening the channel "private-test". So Echo never gets the event.
I tried to delete "private-" prefixes from both php&js side but this time Echo not requiring to authenticate channel anymore since not see as private channel.
The text was updated successfully, but these errors were encountered: