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
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:
?
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.
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 withlaravel-websockets
.The following workaround posted by github user mankms fixed it for me: