pusher and laravel-echo cant subscribe automaticaly to private channel
See original GitHub issue- Echo Version: 1.10.0
- Laravel Version: 8.4.0
- PHP Version: 7.4
- NPM Version: 6.14.6
- Node Version: 4.1.0
- pusher/pusher-php-server: 4.1.5
- pusher-js: 7.0.3
Description:
I use pusher and laravel-echo to create chat app in laravel. public Channels work properly.
I use pusher.com debug console and I realized in PrivateChannel laravel-echo can’t subscribe users to Available private channels automaticaly. notice that commented codes is for public channel.
App\Events\ChatBroad.php
is:
public function broadcastOn()
{
// return new channel('recieve-chat.' . $this->chat['reciever_id']);
return new PrivateChannel('recieve-chat.' . $this->chat['reciever_id']);
}
routes/channels.php
is:
Broadcast::channel('recieve-chat.{reciever_id}', function ($user , $reciever_id) {
return true;
// return $user->id == $reciever_id;
});
and in App\Providers\BroadcastServiceProvider
i use this middleware:
Broadcast::routes(['middleware' => ['auth']]);
bootstrap.js
is:
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: '83b97539662b786ffabb',
cluster: 'eu',
forceTLS: true,
authEndpoint: '/broadcasting/auth',
csrfToken: $('meta[name="csrf-token"]').attr('content'),
});
blade view file:
<script src="{{asset('js/app.js')}}"></script>
<script>
{{--window.addEventListener('DOMContentLoaded' , function () {--}}
{{-- Echo.channel('recieve-chat.{{Auth::id()}}' )--}}
{{-- .listen('ChatBroad', (e) => {--}}
{{-- window.livewire.emit('recieve:' + e.chat.bid_id , e.chat);--}}
{{-- $(chatScrollDown('.chat'+ e.chat.bid_id ));--}}
{{-- });--}}
{{--});--}}
window.addEventListener('DOMContentLoaded' , function () {
Echo.private('recieve-chat.{{Auth::id()}}' )
.listen('ChatBroad', (e) => {
window.livewire.emit('recieve:' + e.chat.bid_id , e.chat);
$(chatScrollDown('.chat'+ e.chat.bid_id ));
});
});
</script>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Laravel Pusher Doesn't Join Private Channel - Laracasts
Hey, there. So I'm using Laravel 5.8, and I have this problem in which my Laravel Echo code doesn't trigger Pusher to join...
Read more >Pusher/Laravel echo error on subscribing to private channel ...
Pusher/Laravel echo error on subscribing to private channel: Auth value for subscription to channel is invalid: should be of format 'key: ...
Read more >Broadcasting - Laravel - The PHP Framework For Web Artisans
When using Laravel Echo, the HTTP request to authorize subscriptions to private channels will be made automatically; however, you do need to define...
Read more >Broadcasting | laravel - GitHub Pages
When using Laravel Echo, the HTTP request to authorize subscriptions to private channels will be made automatically; however, you do need to define...
Read more >Event Broadcasting - Laravel guide
When using Pusher and Laravel Echo, you should specify pusher as your desired ... subscriptions to private channels will be made automatically; however, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
in
App\Providers\BroadcastServiceProvider.php
we dont need any middleware!!
@ben-pusher hey there, if auth endpoint has problem. irecieve 500 error in console. i checked all of this. and i describe the problem and some additional data in here . thank you 🌺