Pusher on a route not sending events in Laravel

I am building a test application using Pusher for Laravel 4 real-time notification. Since I am testing the specified API, I am having difficulty with its operation.

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 watch my application’s Debug Console on Pusher.com, this is what I see: enter image description here

But when I hit the test route, it does not send an event to my Pusher application, and it does not send an API message to my client. But if I use the Create new Event tester on the debug console, I’m sure enough that it will send an API message and my client will receive and update it. enter image description here

Why do you think he cannot send an event to my pusher application on my route? I can not understand, because there is no exception error. Please advice.

+2
source share
4 answers

There are three points by which you can debug your integration with Pusher:

  • Interacting with the Pusher HTTP API (REST)
  • Event execution is accepted by Pusher using the Pusher debug console
  • Ensuring your customer integration is done by checking the pusher-js log

In your situation, you have done 2. and you can see that the events that you are running do not reach the debug console. So you need to do 1.

The Pusher PHP Server library provides detailed information on how to enable debugging: https://github.com/pusher/pusher-php-server#debugging

And how to get journal information from the library: https://github.com/pusher/pusher-php-server#logging

After you receive the registration information for the pusher-php-server library, feel free to publish it so that we can see what might be the problem. do you get a response code without 2xx?

+2
source

for me it was because i used the eu server and laravel is configured automatically on our server

+4
source

To extend the answer to @adutu you need to install

 'cluster' => 'eu' 

Inside the Parameters section of the Pusher driver configuration in broadcasting.php.

+4
source

The problem with this is that you cannot set the host to broadcast the pusher.

This problem only occurs when using the EU cluster, in which case you must change the host to:

 api-eu.pusher.com 

Similarly, you can create your own broadcast driver. which does the same as the default, but sets the host parameter.

I am going to suggest editing for the backlight manager to facilitate this change.

0
source

Source: https://habr.com/ru/post/1265034/


All Articles