2

I'm working on a small chat project, but it seems like Laravel echo is not listening, since I can see the log (message) correctly on pusher website dashboard

this is my code :

mounted: function(){
        
        Echo.private('chat').listen('MessageSent', (e) => {
            console.log(e)
            
        });
    },

This is my bootstrap.js file

import Echo from 'laravel-echo';

window.Pusher = require('pusher-js');

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    forceTLS: true
});


my channel.php


Broadcast::channel('chat', function ($user) {
    return auth()->check();
});

By the way I see the messages on pusher dashboard, but my vue application is not listening

I'm getting in the console:

No callbacks on private-chat

1 Answer 1

2

Put . before event name

Chang this

mounted: function(){
        
        Echo.private('chat').listen('MessageSent', (e) => {
            console.log(e)
            
        });
    },

to this

mounted: function(){
        
        Echo.private('chat').listen('.MessageSent', (e) => {
            console.log(e)
            
        });
    },
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.