Okay, there were a lot of steps, but by taking the test I do not get any feedback from my listener. I noticed that in the laravel-echo-server console, it returns the channel as laravel_database_test-asd
.
So I changed the listener channel in my component from channel ('test-asd')
to channel ('laravel_database_test-asd')
and it works normally.
So my question is: Why is laravel creating a channel with the prefix laravel_database_
?
BROADCAST_DRIVER
andQUEUE_DRIVER
entries in my .env to redis
;routes/channel.php
file with the name test-asd
;MessageSent
;broadcastOn
method I added: `return new Channel ('test-asd');routes/web.php
file with the name test, and added a callback: broadcast(new MessageSent ())
;laravel-echo-server
globally;npm install
;laravel-echo
with npm install laravel-echo
predis/predis
with composer require predis/predis
resources /js/bootstrap.js
file by importing socket.io-client
and pointing socket.io
as broadcaster;Echo.channel('test-asd').listen ('MessageSent', (e) => {}
;I found the reason for this issue. Now config/database.php
configuration file has several information for connection to the Redis, including a key to set the prefix
.
I found a call to this setting in the register method of the Iluminate\Redis\RedisServiceProvider
class.
Why is this not documented?
Hi there,
Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:
Thanks!
@adhenrique
So every channel has prefix xxx_database_
How can I subscribe private channel as the following?
Echo.private(order.${orderId}
)
@xralphack It's not a perfect solution but you could comment the "prefix"
line in database.php. Without that prefix you could then use Echo.private(order.${orderId})
as it is. But as I said it's not a perfect way to go. Best way would just to prefix the channel name like <APP_NAME>_database_<channel-name>
My questions is when client want to join a private channel
echo.private(
App.User.${user.id}).
I have no idea how can I add the prefix.
I did not see Echo has any configuration about this.
First of all this is not the right place for such a question. You can get all the information from the Laravel documentation or you could ask this in laravel forms.
But in short: In case you are looking into the default setting of notifications. Check "Customizing The Notification Channel" part under the Laravel notifications section.
If not, you are looking for broadcasting events. Then you should check your event class which you are broadcasting. You can modify the channel name within the broadcastOn method. Don't forget to change it within routes/channels.php as well. For more on this check Laravel broadcast.
Please sentence the laravel-echo-server to death.
Reason is just the procrastination with each laravel version upgrading.
Please sentence the laravel-echo-server to death.
Reason is just the procrastination with each laravel version upgrading.
It's a good library though, I'd say we need it. Has anyone figured how to add the prefix to laravel echo?
I found the reason for this issue. Now
config/database.php
configuration file has several information for connection to the Redis, including a key to set theprefix
.I found a call to this setting in the register method of the
Iluminate\Redis\RedisServiceProvider
class.Why is this not documented?
Hey thank you so much for this. This was driving me insane. I was wondering why using laradock's built-in laravel-echo-server, I was able to join channels but couldn't get to execute the listen callback function of Echo in my JavaScript code. I noticed in the logs that on connecting to the channel, the output joined channel: xyz
was different from Channel: MyAppName_database_xyz
which led me here.
In the end I just commented out the prefix in config/database.php
, I'm not sure what the overall impact is to the application, but for now it works:
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
// 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
],
This is not documented at all in the current documentation. I'm wondering if this was intentional and I'm missing something or just an oversight.
My findings were that in order to "authenticate" to private channels you cant include that APP_database_private_XXX
prefix, but in order to consume you must!.... Laravel echo lib doesn't support it out of the box, so commenting out the 'prefix' is the only way to get this working
Echo.channel('public-event') // doesnt work because is missing the redis prefix
.listen('.test-event', () => {
console.log('Public')
})
Echo.channel('APP_database_public-event') // this works
.listen('.test-event', () => {
console.log('Public')
})
Echo.private('user.1') // this authenticates successfully, but the listener is never call
.listen('.test-event', () => {
console.log('Private')
})
Echo.private('APP_database_private_user.1') // this fails to authenticate
.listen('.test-event', () => {
console.log('Private')
})
I think this issue shouldn't be closed until it gets documented, we've been trying to solve this for 2 days. Thank you @sevillaarvin
I found the reason for this issue. Now
config/database.php
configuration file has several information for connection to the Redis, including a key to set theprefix
.I found a call to this setting in the register method of the
Iluminate\Redis\RedisServiceProvider
class.Why is this not documented?
Thank's, really helped
@milewski
Nice. it is clear. Follow to him.
I found the reason for this issue. Now
config/database.php
configuration file has several information for connection to the Redis, including a key to set theprefix
.
I found a call to this setting in the register method of theIluminate\Redis\RedisServiceProvider
class.
Why is this not documented?Hey thank you so much for this. This was driving me insane. I was wondering why using laradock's built-in laravel-echo-server, I was able to join channels but couldn't get to execute the listen callback function of Echo in my JavaScript code. I noticed in the logs that on connecting to the channel, the output
joined channel: xyz
was different fromChannel: MyAppName_database_xyz
which led me here.In the end I just commented out the prefix in
config/database.php
, I'm not sure what the overall impact is to the application, but for now it works:'redis' => [ 'client' => env('REDIS_CLIENT', 'predis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'predis'), // 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_', ],
This is not documented at all in the current documentation. I'm wondering if this was intentional and I'm missing something or just an oversight.
It works !! Thank you
Don t work comment 'prefix' now
Don t work comment 'prefix' now
Is your config being cached? try php artisan config:clear
Dont work
If you're using laravel-echo-server you can specify the prefix in the redis database config:
{
"database": "redis",
"databaseConfig": {
"redis": {
"keyPrefix": "app_database_"
},
}
}
I found the reason for this issue. Now
config/database.php
configuration file has several information for connection to the Redis, including a key to set theprefix
.
I found a call to this setting in the register method of theIluminate\Redis\RedisServiceProvider
class.
Why is this not documented?Hey thank you so much for this. This was driving me insane. I was wondering why using laradock's built-in laravel-echo-server, I was able to join channels but couldn't get to execute the listen callback function of Echo in my JavaScript code. I noticed in the logs that on connecting to the channel, the output
joined channel: xyz
was different fromChannel: MyAppName_database_xyz
which led me here.In the end I just commented out the prefix in
config/database.php
, I'm not sure what the overall impact is to the application, but for now it works:'redis' => [ 'client' => env('REDIS_CLIENT', 'predis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'predis'), // 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_', ],
This is not documented at all in the current documentation. I'm wondering if this was intentional and I'm missing something or just an oversight.
Guys it's better to just update your .env
file. e.g:
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_PREFIX=YOUR_PREFIX_HERE_OR_LEAVE_EMPTY
Most helpful comment
I found the reason for this issue. Now
config/database.php
configuration file has several information for connection to the Redis, including a key to set theprefix
.I found a call to this setting in the register method of the
Iluminate\Redis\RedisServiceProvider
class.Why is this not documented?