I am using Laravel 5.8, and using Laravel pusher "^4.1". Laravel pusher was working fine before 2 days ago.
On that day I had updated Laravel composer and global laravel/installer to install new (another) Laravel app. And, today when I am testing the old app the Laravel pusher is not working. It is throwing following error:
Illuminate\Broadcasting\BroadcastException in D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Broadcasting\Broadcasters\PusherBroadcaster.php:119
Stack trace:
#0 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Broadcasting\BroadcastEvent.php(48): Illuminate\Broadcasting\Broadcasters\PusherBroadcaster->broadcast(Array, 'amenity-uploade...', Array)
#1 [internal function]: Illuminate\Broadcasting\BroadcastEvent->handle(Object(Illuminate\Broadcasting\Broadcasters\PusherBroadcaster))
#2 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)
#3 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#5 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#6 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#7 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#8 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Broadcasting\BroadcastEvent))
#9 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#10 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(Illuminate\Broadcasting\BroadcastEvent), false)
#11 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#12 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(337): Illuminate\Queue\Jobs\Job->fire()
#13 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(283): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
#14 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
#15 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(102): Illuminate\Queue\Worker->daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
#16 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('database', 'default')
#17 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#18 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)
#19 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#20 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#21 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#22 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Command.php(183): Illuminate\Container\Container->call(Array)
#23 D:\wamp64\www\amenity\vendor\symfony\console\Command\Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#24 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#25 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(1012): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(272): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(133): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 D:\wamp64\www\amenity\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 {main}
My event file looks like:
class AmenityUploaded implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $property_id;
/**
* Create a new event instance.
*
* AmenityUploaded constructor.
* @param $property_id
*/
public function __construct($property_id)
{
$this->property_id = $property_id;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
// return new PrivateChannel('channel.amenity.'.$this->property_id);
return ['channel.amenity'];
}
public function broadcastAs()
{
return 'amenity-uploaded';
}
public function broadcastWith()
{
// This must always be an array. Since it will be parsed with json_encode()
$prop = Property::find($this->property_id);
$trash = "";
$warning = "";
if($prop->completed == 1){
$main = "<a href='".url('/admin/floor-stack/?company='.$prop->company_id.'&property='.$this->property_id)."' class='btn btn-xs btn-primary d-inline-block mr-1'>View</a>";
$trash = "<a href='#' class='btn btn-xs bg-light-grey delete_amenity mr-1'><i class='fa fa-trash text-white' aria-hidden='true'></i></a>";
}elseif($prop->completed == 2){
$main = "<a href='#' class='btn btn-xs btn-warning d-inline-block mr-1'>Pending</a>";
}elseif($prop->completed == 3){
$notice = Notice::where('property_id',$this->property_id)->where('file_type','1')->first();
$main = "<a href='".url('/admin/floor-stack/?company='.$prop->company_id.'&property='.$this->property_id)."' class='btn btn-xs btn-primary d-inline-block mr-1'>View</a>";
$trash = "<a href='#' class='btn btn-xs bg-light-grey delete_amenity'><i class='fa fa-trash text-white' aria-hidden='true'></i></a>";
$warning = "<a class='d-inline-block' href='".url('/admin/notice/'.$notice->slug)."' data-toggle='tooltip' data-html='true' title='The upload has some potential errors. Please click here to check which errors were detected.'><i class='fa fa-exc fa-exclamation-circle text-warning align-middle' aria-hidden='true'></i></a>";
}else{
$main = "<a href='".url('/admin/property/create/'.$this->property_id)."' class='btn btn-xs btn-secondary d-inline-block mr-1'><i class='fa fa-arrow-circle-up' aria-hidden='true'></i> Upload</a>";
}
return [
'id' => $this->property_id,
'main' => $main,
'trash' => $trash,
'warning' => $warning
];
}
}
channel subsription
var pusher = new Pusher("{{config('broadcasting.connections.pusher.key')}}", {
cluster: 'us3',
forceTLS: true
});
/** channel.amenity **/
let channelAmenity = pusher.subscribe(`channel.amenity`);
channelAmenity.bind('amenity-uploaded', function(data) {
// console.log(data);
$('#am_div_'+data.id).html(data.main+data.trash+' '+data.warning);
});
And, event is being fired from a Laravel job as :
event(new AmenityUploaded($this->data['property_id']));
It just changed the status of a Laravel job from running to completed.
Update:
.env
APP_NAME=Amenity
APP_ENV=local
APP_KEY=base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
APP_DEBUG=true
APP_URL=http://amenity.local
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=am_db_prod
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=43200
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=xxxxxxxx
MAIL_PASSWORD=xxxxxxx
MAIL_ENCRYPTION=tls
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=xxxxxxx
PUSHER_APP_KEY=xxxxxxxxxxxxxxxxxxxxx
PUSHER_APP_SECRET=xxxxxxxxxxxxxxxxxx
PUSHER_APP_CLUSTER=us3
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
WKHTML=vendor\wemersonjanuario\wkhtmltopdf-windows\bin\64bit\wkhtmltopdf
broadcasting.php
'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
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
'log' => [
'driver' => 'log',
],
'null' => [
'driver' => 'null',
],
],
update2:
If i sent data from Debug Console pusher.com, the data is being pushed to the website and could see on console successfully.
pusher-php-server: 4.1.4, please try to downgrade to 4.1.3 by consolecomposer require pusher/pusher-php-server:"4.1.3"- haidang