Reputation: 89
In laravel-echo-console:
L A R A V E L E C H O S E R V E R
version 1.5.2
⚠ Starting server in DEV mode...
✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for redis events...
Server ready!
[7:07:00 PM] - YSTAl2zDJP0HtuoCAAAA joined channel: public
[7:07:00 PM] - Sending auth request to: https://xxxxx/broadcasting/auth
[7:07:00 PM] - YSTAl2zDJP0HtuoCAAAA authenticated for: private-survey.2
[7:07:00 PM] - YSTAl2zDJP0HtuoCAAAA joined channel: private-survey.2
Channel: laravel_database_private-survey.2
Event: server.message
All looks fine, but I can't recieve this message in browser:
window.Echo.private('survey.2')
.listen('.server.message', (e) => {
console.log(e)
});
e {events: {…}, name: "private-survey.2", socket: p, options: {…}, eventFormatter: t}
My event class:
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new PrivateChannel('survey.2');
}
public function broadcastAs()
{
return 'server.message';
}
In laravel telescope I see:
{
message: "wdfwsfwf",
socket: null
}
does it normal that socket is null? Also always 0 listeners for this event.
What's wrong?
Upvotes: 0
Views: 251
Reputation: 305
According to https://github.com/laravel/framework/issues/28210
Commenting out the 'prefix'
line for redis in config/database.php
should make the trick, although I'd avise to read the link further for more insight.
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
// 'prefix' => Str::slug(env('APP_NAME', 'laravel'), '_').'_database_',
],
Upvotes: 0
Reputation: 89
my problem was here Channel: laravel_database_ private-survey.2
change this in config/database.php
echo must join to "survey.2
" in this case
if broadcasAs
public function broadcastAs()
{
return 'server.message';
}
echo must listen ".
server.message" - dot
before says not using namespace - this is event - not channel!
Upvotes: 1