Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pusher on route not sending event in Laravel

I am creating a test app using Pusher for real-time notification on Laravel 4. As I am testing the said API, I am having difficulties on making it work.

I have this on my routes.php:

Route::get('pusher-test', function(){
    return View::make('pages.test');
});
Route::any('test', function(){
        $pusher = new Pusher('key','sect','app_key'); //my keys are correct.
        $pusher->trigger('notificationChannel', 'userRegistration', []);
});

Then my pusherTest.js file:

(function(){
    var pusher = new Pusher('key');
    var channel = pusher.subscribe('notificationChannel');
        channel.bind('userRegistration', function(data){
            $('.test').append('HEY!');
        }); 
})();

My view page:

<html>
    <head>
        <meta charset="utf-8">
        {{ HTML::style('_/css/bootstrap.css') }}
        {{ HTML::style('_/css/mystyle.css') }}
    </head>
    <body>
        <h2>HI!</h2>
        <div class="test"></div>
        {{ HTML::script('_/js/bootstrap.js') }}
        {{ HTML::script('_/js/jquery.js') }}
        {{ HTML::script('_/js/pusher/pusher.min.js')}}
        {{ HTML::script('_/js/pusherTest.js')}}
    </body>
</html>

When I try to observe the Debug Console of my app on Pusher.com, here's what I see: enter image description here

But when I hit the test route, it is not sending an event on my Pusher app, neither it sends the API message to my client. But if I will use the Create new Event tester on debug console, sure enough it sends the API message and my client receives and updates it. enter image description here

What do you think is happening why on my route it can't send the event to my pusher app? I can't figure it out because is has no exception error. Please advice.

like image 909
Jay Marz Avatar asked Nov 20 '25 06:11

Jay Marz


1 Answers

for me it was because I used the eu server and laravel is configured automatically on us server

like image 180
adutu Avatar answered Nov 23 '25 01:11

adutu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!