Search code examples
pusherlaravel-5.4laravel-echo

Laravel 5.4 Broadcast : Pusher->Error->WebSocketError


I just began to use Broadcasting with Pusher and Echo. My problem is that I'm getting an error and I can't find how to resolve it. The error message look pretty straigthfoward, but I have no idea where I should head to get rid of it.

My laravel is an upgrade from Laravel 5.3. I uncommented the App/Providers/BroadcastServiceProvider::class into config.php. I created an event and set the Private channel.return new PrivateChannel('dealer.'$this->client->dealer_id); I added the new channel into routes/channels.php

Broadcast::channel('dealer.{dealerId}', function ($user, $dealerId) {
    return (int) $user->dealer_id === (int) $dealerId;
});

I added this to bootstrap.js

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: 'my-secrect-key'
});

I also added everything to the .env file. Finally, I added the channel to the script at the end of the applayout.blade.php

Echo.private(`dealer.1`)
    .listen('NewClient', (e) => {
    console.log(e);
});

When I load the page, this is the error I got from the console:

Pusher : Error : {
    "type":"WebSocketError",
    "error":{
        "type":"PusherError",
        "data":{
            "code":null,
            "message":"Auth value for subscription to private-dealer.1 is invalid: should be of format 'key:signature'"
        }
    }
}

What am I missing/doing wrong?


Solution

  • Upgrading Laravel 5.3 to 5.4 you should make changes in your .env file

    Change From:

    PUSHER_KEY
    PUSHER_SECRET
    

    to

    PUSHER_APP_KEY
    PUSHER_APP_SECRET
    

    Someone answered it on Laracast. Link