Laravel 8 not broadcasting an event (pusher)

I just started with laravel pusher. When broadcasting an event I am getting this error. I can able to see event is firing in pusher degub console. I am not understanding what this error is related to. I need help to understand where I am going wrong.

{message: "Undefined property: stdClass::$channels", exception: "ErrorException",…}
exception: "ErrorException"
file: "C:xampphtdocsrealtimechatvendorpusherpusher-php-serversrcPusher.php"
line: 538
message: "Undefined property: stdClass::$channels"
trace: [{file: "C:xampphtdocsrealtimechatvendorpusherpusher-php-serversrcPusher.php", line: 538,…},…]

this is my code

 public function sendMessage(Request $request)
    {
       event(new MessageEvent());
    }

event

class MessageEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    

    public function __construct()
    {
        
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return IlluminateBroadcastingChannel|array
     */
    public function broadcastOn()
    {
        return new Channel('channel-name');
    }

    public function broadcastAs()
    {
        return 'userChatChannel';
    }
}

Thank you

Answer

For detail info you can go through the below thinks

https://github.com/pusher/pusher-http-php/issues/295
https://stackoverflow.com/questions/66624416/pusher-undefined-property-stdclasschannels-in-laravel-lumen

the problem was the version pusher 5.0 is broken. so to fixed this you have to edit your composer.json file

from

"pusher/pusher-php-server": "5.0"

to

"pusher/pusher-php-server": "^5.0"

after this run composer update command

Leave a Reply

Your email address will not be published. Required fields are marked *