skip to Main Content

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:

IlluminateBroadcastingBroadcastException in D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateBroadcastingBroadcastersPusherBroadcaster.php:119
Stack trace:
#0 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateBroadcastingBroadcastEvent.php(48): IlluminateBroadcastingBroadcastersPusherBroadcaster->broadcast(Array, 'amenity-uploade...', Array)
#1 [internal function]: IlluminateBroadcastingBroadcastEvent->handle(Object(IlluminateBroadcastingBroadcastersPusherBroadcaster))
#2 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(32): call_user_func_array(Array, Array)
#3 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(90): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#4 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(34): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#5 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerContainer.php(576): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#6 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateBusDispatcher.php(94): IlluminateContainerContainer->call(Array)
#7 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminatePipelinePipeline.php(128): IlluminateBusDispatcher->IlluminateBus{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#8 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminatePipelinePipeline.php(104): IlluminatePipelinePipeline->IlluminatePipeline{closure}(Object(IlluminateBroadcastingBroadcastEvent))
#9 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateBusDispatcher.php(98): IlluminatePipelinePipeline->then(Object(Closure))
#10 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueCallQueuedHandler.php(49): IlluminateBusDispatcher->dispatchNow(Object(IlluminateBroadcastingBroadcastEvent), false)
#11 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueJobsJob.php(88): IlluminateQueueCallQueuedHandler->call(Object(IlluminateQueueJobsDatabaseJob), Array)
#12 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueWorker.php(337): IlluminateQueueJobsJob->fire()
#13 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueWorker.php(283): IlluminateQueueWorker->process('database', Object(IlluminateQueueJobsDatabaseJob), Object(IlluminateQueueWorkerOptions))
#14 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueWorker.php(118): IlluminateQueueWorker->runJob(Object(IlluminateQueueJobsDatabaseJob), 'database', Object(IlluminateQueueWorkerOptions))
#15 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueConsoleWorkCommand.php(102): IlluminateQueueWorker->daemon('database', 'default', Object(IlluminateQueueWorkerOptions))
#16 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateQueueConsoleWorkCommand.php(86): IlluminateQueueConsoleWorkCommand->runWorker('database', 'default')
#17 [internal function]: IlluminateQueueConsoleWorkCommand->handle()
#18 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(32): call_user_func_array(Array, Array)
#19 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(90): IlluminateContainerBoundMethod::IlluminateContainer{closure}()
#20 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerBoundMethod.php(34): IlluminateContainerBoundMethod::callBoundMethod(Object(IlluminateFoundationApplication), Array, Object(Closure))
#21 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateContainerContainer.php(576): IlluminateContainerBoundMethod::call(Object(IlluminateFoundationApplication), Array, Array, NULL)
#22 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateConsoleCommand.php(183): IlluminateContainerContainer->call(Array)
#23 D:wamp64wwwamenityvendorsymfonyconsoleCommandCommand.php(255): IlluminateConsoleCommand->execute(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#24 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateConsoleCommand.php(170): SymfonyComponentConsoleCommandCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(IlluminateConsoleOutputStyle))
#25 D:wamp64wwwamenityvendorsymfonyconsoleApplication.php(1012): IlluminateConsoleCommand->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#26 D:wamp64wwwamenityvendorsymfonyconsoleApplication.php(272): SymfonyComponentConsoleApplication->doRunCommand(Object(IlluminateQueueConsoleWorkCommand), Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#27 D:wamp64wwwamenityvendorsymfonyconsoleApplication.php(148): SymfonyComponentConsoleApplication->doRun(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#28 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateConsoleApplication.php(90): SymfonyComponentConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#29 D:wamp64wwwamenityvendorlaravelframeworksrcIlluminateFoundationConsoleKernel.php(133): IlluminateConsoleApplication->run(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#30 D:wamp64wwwamenityartisan(37): IlluminateFoundationConsoleKernel->handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
#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 IlluminateBroadcastingChannel|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>&nbsp;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+'&nbsp;'+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=vendorwemersonjanuariowkhtmltopdf-windowsbin64bitwkhtmltopdf

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.

2

Answers


  1. When reverse engineering this from the Laravel sources you can see the broadcast exception is only thrown in a single place. Which is only done in case the pusher response was anything else that an HTTP 2xx response code.
    Perhaps the quickest way to get to the response content would to add a "dump and die" statement (I know this is a poor mans debug option, but a very effective alternative to setup Xdebug etc.). This output would definitely help you to get to the root cause.

    # src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php on line 112
    $response = $this->pusher->trigger(
        $this->formatChannels($channels), $event, $payload, $socket, true
    );
    
    dd($response); // << Add this line to get the response content
    
    Login or Signup to reply.
  2. I had similar issue, and setting 'useTLS' => false, had fixed the issue. It looks like you have the same issue. Try

    'options' => [
        'cluster' => env('PUSHER_APP_CLUSTER'),
        'useTLS' => false,
    ],
    

    You can check one of the related issues https://github.com/pusher/pusher-http-php/issues/231 here, and how to know the exact issue. May be you have some issues too that’s why you are unable to make connection.

    By the way, I am not sure, if it safe to do so. Some expert might give opinion on that one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search