skip to Main Content

I’m trying to make real-time laravel app with beyondcode’s laravel-websockets, and pusher-php-server following this manual. But i didnt specify the version of the pusher/pusher-php-server package because it requires an outdated php version.

I created "NewTrade" event implements "ShouldBroadcastNow"
Then I triggered the event by running the following with tinker:

event (new AppEventsNewTrade('test'))

It returns:

>>> event (new AppEventsNewTrade('test'));
=> [
    null,
]

"broadcastOn" method of NewTrade event fired

    public function broadcastOn()
    {

        $test = new AppModelsTest();
        $test->title = "event";
        $test->save();

        return new Channel('trades');
    }

I see this in the database, new records are being created in the Test table.
But in websockets dashboard ( http://127.0.0.1:8000/laravel-websockets ) no info about this event.

Help pls(( What am I doing wrong?

2

Answers


  1. Maybe you haven’t configured app (.env file) properly.

    Heres official laravel-websockets docs
    https://beyondco.de/docs/laravel-websockets/getting-started/introduction

    For Laravel docs on broadcasting and websockets you can checkout
    https://laravel.com/docs/9.x/broadcasting#introduction

    Have you ran:

    php artisan websockets:serve
    

    ?

    Also, I was struggling hard to setup this package with Laravel Sail (Docker), ended up switching to Soketi instead because for what ever reason, events were never caught, just like issue you are having.
    So most likely your problem is configuration related.

    Login or Signup to reply.
  2. i didnt specify the version of the pusher/pusher-php-server package because it requires an outdated php version.

    I made the same mistake and ended up struggling with this issue for hours.

    Apparently, the latest version of pusher-php-server is not compatible with laravel-websockets.

    The following workaround posted by github user mankms fixed it for me:

    # run this command from the root directory of your Laravel app
    composer require pusher/pusher-php-server:7.0.2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search