Category : laravel-broadcast

I’m trying to authorize a private channel. I’m using Vue.js as SPA, Laravel Sanctum for auth, and Laravel for api. As the Laravel’s documentation, I wrote my channel callbacks on "channels.php" under "routes" folder. But it wasn’t working. It was saying 403 when I tried to authenticate the channel. Then I moved my channel callbacks ..

Read more

I am getting 405 (Method not allowed) status for laravel private channel from reactJS. This is working for userId=1 but returning 405 for all other users. Here is the code for Laravel class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Broadcast::routes([ "middleware" => ..

Read more

I am getting 401 (Unauthorized) status for laravel private channel from reactJS. This is working for userId=1 but returning 401 for all other users. Here is the code for Laravel class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { Broadcast::routes([ "middleware" => [‘api’, ‘jwt.auth’], ..

Read more

event is: public $chat ; public function __construct($chat) { $this->chat = $chat; } public function broadcastOn() { // return new Channel(‘recieve-chat’); return new PrivateChannel(‘recieve-chat’ ); } routes/channels.php is: Broadcast::channel(‘recieve-chat’, function ($user ) { return true; // return $user->id === $reciever_id; }); in blade file: <script> window.addEventListener(‘DOMContentLoaded’ , function () { Echo.private(‘recieve-chat’) .listen(‘ChatBroad’, (e) => { ..

Read more

I’ve been stuck with Broadcasting on private channel in authentication part. What I have done is, I made custom authEndpoint in Echo server "authEndpoint": "/broadcastAuth", Controller: public function broadcastAuth(Request $request){ $channel = $this->normalizeChannelName($request->channel_name); $broadcaster = new CustomBroadcaster(); $channelAuth = $broadcaster->verifyUserCanAccessChannel($request, $channel); if($channelAuth){ return true; } return response()->json([ ‘message’ => ‘Not allowed’ ], 403); } I ..

Read more

I am having an issue with the auth:api guard working with broadcasting. I get the error Class AppHttpMiddlewareAuthenticate:api does not exist if I call php artisan route:list. BroadcastServiceProvider.php: <?php namespace AppProviders; use IlluminateSupportFacadesBroadcast; use IlluminateSupportServiceProvider; class BroadcastServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { ..

Read more

If I set my channel like this, I get console error 403. note:: if ($user->statue) isn’t reg. Broadcast::channel(‘using’, function ($user) { if($user->status==’reg’){ return $user->id; } }); If I set my channel like this, everything is okay. Broadcast::channel(‘using’, function ($user) { if($user->status==’reg’){ return $user->id; }else{ return ‘invalid’; } }); But I need to set my chennel ..

Read more

I’m building an application on Laravel ^7.0 where some of my module needs SSL so I created a development environment with vhost on Xampp. I created a SSL Certificate through openssl and configured with following: <VirtualHost *:443> ServerAdmin [email protected] DocumentRoot “/Applications/XAMPP/xamppfiles/htdocs/confidence-web-version-3/public” ServerName confid.local ServerAlias www.confid.local SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /Applications/XAMPP/xamppfiles/etc/ssl/localhost.crt SSLCertificateKeyFile /Applications/XAMPP/xamppfiles/etc/ssl/localhost.key <Directory “/Applications/XAMPP/xamppfiles/htdocs/confidence-web-version-3/public”> ..

Read more