blackpenpress
1 week ago

Laravel echo, pusher not authenticating on private channel

Posted 1 week ago by blackpenpress

I'm trying to set up a private pusher channel with echo on laravel 6. It won't authorise the user. The best I can do is get the following response from pusher

Pusher : No callbacks on private-App.User.1 for pusher:subscription_error

I've followed the documentation, I've registered:

App\Providers\BroadcastServiceProvider

added the csrf token:

<meta name="csrf-token" content="{{ csrf_token() }}">

adjusted the broadcast routes in the broadcastServiceProvider

Broadcast::routes(["middleware" => ["auth:api"]]);

Required the channels file

require base_path('routes/channels.php');

Here's the channel code, (the log isn't even running)

Broadcast::channel('App.User.{id}', function ($user, $id) {

   Log::info('User failed to auth.');
   return (int) $user->id === (int) $id;
});

Here's the bootstrap.js code, obviously using my genuine key and endpoint (tried with and without the endpoint)

import Echo from 'laravel-echo'

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

window.Echo = new Echo({
  broadcaster: 'pusher',
  key: 'mykeyhere111',
  cluster: 'eu',
  authEndpoint: "https://mydomain.test/broadcasting/auth",
  forceTLS: true
});

Pusher.logToConsole = true;

console.log(window.Echo.options);

and my vue listen method:

Echo.private(`App.User.${userId}`)

      .notification( (notification) => {

            console.log(notification)
 })

I've also set the env file

BROADCAST_DRIVER=pusher

PUSHER_APP_ID=akeyhere1
PUSHER_APP_KEY=akeyhere123
PUSHER_APP_SECRET=akeyhere12345
PUSHER_APP_CLUSTER=eu

I'm working on homestead with ssl, also tried on vagrant. The network response for auth is:

Request URL: https://mydomain.test/broadcasting/auth
Request Method: POST
Status Code: 302 

with no response data.

I've spent a couple of days trying to get this working, nothing seems to do it. Any ideas?

Please sign in or create an account to participate in this conversation.