Laravel Socket.io,Redis event is broadcasting but not showing on client side
Laravel Socket.io,Redis event is broadcasting but not showing on client side
In my laravel.log i can see the event is broadcasting on the channel i.e.
laravel.log
[2018-08-30 13:41:27] local.INFO: Broadcasting [AppEventsNewRating] on channels [rating] with payload:
"music":
"id": 42,
"name": "1535368873_admin.mp3",
"path": "public/music/1535368873_admin.mp3",
"rating": 53,
"user_id": 4,
"created_at": "2018-08-27 11:21:13",
"updated_at": "2018-08-27 11:21:13",
"is_last_played": 1,
"is_now_playing": 0,
"location_id": 1
,
"socket": null
As of i know i have done everything according to requirement.my redis server is running.laravel-echo-server is running and it is joining my channel i.e.
redis
laravel-echo-server
[18:41:24] - VX9bkHqs-QHRv3MvAAAC joined channel: rating
This is where i am subscribing to the channel and listening to the event
window.app = new Vue(
el: '#app',
beforeMount: function ()
alert("asdas");
this.joinPublicChatChannel();
,
methods:
joinPublicChatChannel: function ()
Echo.channel('rating').listen('App\Events\NewRating', (event) =>
console.log("Event fired!"); //This doesnt work
);
);
and this is my event class
class NewRating implements ShouldBroadcastNow
array
*/
public function broadcastOn()
return new Channel('rating');
and this is my env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel_restaurant
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=
Dont know the reason behind :/
UPDATE
Just cleared all the caches, Now im getting this in laravel-echo-server console
laravel-echo-server
Channel: rating
Event: AppEventsNewRating
Channel: rating
Event: AppEventsNewRating
Channel: rating
Event: AppEventsNewRating
1 Answer
1
Never Mind, I got this running :). just cleared the caches and in
Echo.channel('rating').listen('App\Events\NewRating', (event) =>
console.log("Event fired!"); //This doesnt work
);
I used NewRating instead of App\Events\NewRating
NewRating
App\Events\NewRating
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.