I have recently delved into Laravel 5.3\'s Laravel-Echo and Pusher combination. I have successfully set up public channels and moved on to private ones. I am having trouble
I solve it by creating channel route.
Create your Authorizing Channels in routes->channels.php
Broadcast::channel('chatroom', function ($user) {
return $user;
});
See Documentation : https://laravel.com/docs/5.4/broadcasting#authorizing-channels
thanks
What worked for me was to use the method private of the Laravel Echo package: https://laravel.com/docs/5.3/notifications#listening-for-notifications
Echo.private('App.User.1')
.notification((notification) => {
console.log(notification.type);
});
In my case the problem was a wrong user id:
Echo.private('user.'+CURRENT_USER_ID_HERE)
Error 403 /broadcasting/auth with Laravel version > 5.3 & Pusher, you need change your code in resources/assets/js/bootstrap.js with
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'your key',
cluster: 'your cluster',
encrypted: true,
auth: {
headers: {
Authorization: 'Bearer ' + YourTokenLogin
},
},
});
And in app/Providers/BroadcastServiceProvider.php change by
Broadcast::routes()
with
Broadcast::routes(['middleware' => ['auth:api']]);
or
Broadcast::routes(['middleware' => ['jwt.auth']]); //if you use JWT
it worked for me, and hope it help you.
This can happen if you are no longer logged in. Make sure you are actually logged into the Laravel app and that your current session hasn't expired.
I logged back in and it worked for me.
Check how you are authorising your channel. Depending on your setup this might help. Update your BroadcastServiceProvider with the following:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes(['middleware' => ['auth:api']]);
require base_path('routes/channels.php');
}
}
Adds in the Auth API middleware for use with Laravel Passport.