Not receiving events from pusher
See original GitHub issueHi guys, I need to implement Laravel Echo in my project for broadcasting, and I have followed the documentation precisely, but Echo does not seem to be working, since events do come to pusher debug console, but i’m not able to see them in the browser. below are the most important pieces of code:
.env:
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=0000000000000
PUSHER_APP_KEY=-----------------------------
PUSHER_APP_SECRET=-----------------------
PUSHER_APP_CLUSTER=ap2
broadcasting:
'default' => env('BROADCAST_DRIVER', 'pusher'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
],
],
channels.php (PS. note: always returned true in logs):
Broadcast::channel('App.User.{id}', function ($user, $id) {
\Illuminate\Support\Facades\Log::info("Load from channel");
\Illuminate\Support\Facades\Log::info((int) $user->id === (int) $id);
return (int) $user->id === (int) $id;
});
FavoriteCreate.php:
FavoriteCreated implements ShouldBroadcast
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new PrivateChannel('App.User.' . $this->favorite->favorable->id);
}
public function broadcastAs()
{
return 'favorite.created';
}
app.blade.php: (I suspect that defer
may have something to do with it):
<main class="py-4">
@yield('content')
</main>
</div>
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}"></script>
@yield('js')
BroadcastingServiceProvider.php:
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
bootstrap.js
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: '00000000000000',
cluster: 'ap2',
forceTLS: true
});
webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps();
NotificationsComponent.vue:
created() {
Echo.private('App.User.'+this.user)
.listen('favorite-created', (e) => {
console.log(e);
})
}
Pusher DebugConsole:
API MESSAGE
Channel: private-App.User.3, Event: Illuminate\Notifications\Events\BroadcastNotificationCreated
06:00:45
API MESSAGE
Channel: private-App.User.3, Event: favorite.created
Any help is highly appreciated since I have been working on this for the last four days without any success.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Pusher is not receiving events from the server - Laracasts
Pusher is not receiving events from the server. Hi, my page connects to pusher fine. it subscribes and everything. Im following the instructions...
Read more >Pusher is not receiving events from the server - Stack Overflow
and applying it to my project. somehow, pusher is not receiving my events. the debug console is not showing the "API MESSAGE" from...
Read more >Pusher Channels Protocol
Every message on a Pusher Channels WebSocket connection is packaged as an 'event', whether it is user-generated, or if it is a message...
Read more >[Reactive Pusher Client] Pusher_MessageReceived not working
When I click on Send Event button It is showing me Message Sent! but I didn't get the message in Pusher_MessageRecived handler. Please...
Read more >Debugging your client-side integration with Pusher
Is the subscription to the channel succeeding? Pusher : No callbacks on test-channel for pusher:subscription_succeeded; Is the event being received and does the ......
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
Just went through this myself. You need to add namespace:‘’ to your Echo constructor options. Echo defaults to app.events for the namespace. Since you’re using broadcastAs, the namespace isn’t part of the event name. Of course this means if you are broadcasting anything without doing a broadcastAs, then you’ll have to subscribe to the fully qualified name (App\Events\WhatEver).
Hi, sorry to open this again without a solution but I and others seem to have a similar problem
https://github.com/beyondcode/laravel-websockets/issues/420
I am able to see the events in the websockets dashboard, but they are not being picked up on the frontend.
I ave this working on production with a similar config and would like to open a discussion about duplicating this and finding a solution as others will likely experience a similar problem
https://stackoverflow.com/questions/61120893/laravel-websockets-laravel-echo-doesnt-listen-my-events