简体   繁体   中英

Laravel Pusher Error “No Callback” Error

I am trying to build real time Notifications using Laravel 5.3 and Pusher for my Web-Applicatin. I am able to push messages to Pusher debug console. My Server-side script:

$options = array(
                    'cluster' => 'ap2',
                    'encrypted' => true
            );
            $pusher = new Pusher(
                    'xxxxxxxxxx', // removed for safety
                    'xxxxxxxxxx', // removed for safety
                    'xxxxx', // removed for safety
                    $options
            );

            $data['message'] = ($user->name)." like your status";
            $pusher->trigger('my-channel', 'PusherEvent', $data);

And my Client-side Script:

<script src="https://js.pusher.com/4.0/pusher.min.js"></script>

// Enable pusher logging - don't include this in production
Pusher.logToConsole = true;

var pusher = new Pusher('xxxxxxxxx', {
  cluster: 'ap2',
  encrypted: true
});

var channel = pusher.subscribe('my-channel');
channel.bind('PusherEvent', function(data) {
  alert(data.message);
});

I want to get alert on my webpage.Javascript is enabled in my browser.My browser console shows something like this:

Pusher : Event sent : {"event":"pusher:subscribe","data":{"channel":"my-channel"}} pusher.min.js:8:2594
Pusher : Event recd : {"event":"pusher_internal:subscription_succeeded","data":{},"channel":"my-channel"}
Pusher : No callbacks on my-channel for pusher:subscription_succeeded

What might be the reason for this ??

You don't have any bindings for an event called pusher_internal:subscription_succeeded . This is normal and nothing to worry about. When you subscribe to a channel an event is fired which you aren't listening for.

If you got an event called PusherEvent and got that callback message you should be concerned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM