I'm broadcasting events from Lumen 5.4 to Pusher. Everything works fine on my local machine, with PHP V7.0.22. However when I deploy my code to my Elastic Beanstalk instance running the same PHP version. Nothing happens.
Here is an example event I'm testing with;
Calling The Event
use App\Events\ExampleEvent;
$app->get('/event', function(){
$message = "Hello Haseeb";
event(new ExampleEvent($message));
return "Complete";
});
Example Event
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
class ExampleEvent extends Event
{
public $message;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new Channel('nai-btana');
}
public function broadcastAs() {
return 'coolest-event-ever';
}
}
Again this works absolutely fine from localhost. I can see the events on the pusher debug console and also consume the messages on the front-end (Vue). However the exact same event does not fire from my EB instance (Linux AMI).
I'm using the below script to test pusher. Test Script
$app->get('/event', function(){
error_reporting(E_ALL);
$app_id = env('PUSHER_APP_ID');
$app_key = env('PUSHER_KEY');
$app_secret = env('PUSHER_SECRET');
class MyLogger {
public function log( $msg ) {
print_r( $msg . "<br />" );
}
}
$pusher = new Pusher($app_key, $app_secret, $app_id, array( 'cluster' => 'ap2' ));
$logger = new MyLogger();
$pusher->set_logger( $logger );
$data['message'] = 'hello world';
$result = $pusher->trigger('simple', 'simple', $data);
$logger->log( "---- My Result ---" );
$logger->log( $result );
return "Complete";
});
Unfortunately I get the same response on both local and server. 200 OK Response
Pusher: ->trigger received string channel "simple". Converting to array.
Pusher: create_curl( http://api-ap2.pusher.com:80/apps/674397/events?auth_key=277a5f98b54adff6fbff&auth_signature=13921666bca17192ef8fdb717d086f828428eef41ecbe9b13460e952ab4cf489&auth_timestamp=1546792861&auth_version=1.0&body_md5=93926a8b33af11740f1903f0a7102fbf )
Pusher: trigger POST: {"name":"simple","data":"{\"message\":\"hello world\"}","channels":["simple"]}
Pusher: exec_curl response: Array ( [body] => {} [status] => 200 )
---- My Result ---
1
Complete
The test event shows up in Pusher's debug console. But the same event does not emit when I broadcast via Laravel Event. There is no error when using Event Broadcasting but no result either.