Closed szabrzyski closed 1 year ago
I also lowered version for stable work laravel-websockets)
Workaround
composer require pusher/pusher-php-server:7.0.2
Holy shit. Thanks @szabrzyski ! I've been struggling with this for 1½ weeks now and couldn't figure out why my client side didn't catch the event.
Когда планируется обновления? На 7.2 много чего который хотели бы пробовать.
I have traced the issue to this: https://github.com/pusher/pusher-http-php/pull/329/files#r993378977
TLDR, the new payload for when dispatching to one channel is channel
not channels
.
Also experiencing this issue.
A bug report has been filed also at pusher/pusher-http-php#351
@luceos Strange, actually beyondcode/laravel-websockets does accept both channel and channels:
Have you actually tested a patch that solves the issue?
I don't know then @madpilot78; truth be told I have a fork because I needed a custom implementation for a @Flarum extension. And in this fork it now works. Diffing the last version with the new one, and testing things locally, only the channel change has been the most apparent one.
The code you mentioned, which correctly adds the ability to read channel
if it is set, was only merged into master 8 days ago, whereas the last release is from March for 1.x. I assume that's the culprit, these changes haven't been released yet and so any published version of this package will still only allow channels
in the payload.
I don't know then @madpilot78; truth be told I have a fork because I needed a custom implementation for a @flarum extension. And in this fork it now works. Diffing the last version with the new one, and testing things locally, only the channel change has been the most apparent one.
No you're probably right, I'm going to test again.
The code you mentioned, which correctly adds the ability to read
channel
if it is set, was only merged into master 8 days ago, whereas the last release is from March for 1.x. I assume that's the culprit, these changes haven't been released yet and so any published version of this package will still only allowchannels
in the payload.
Oh, sorry, my bad I did not check when it was added. Then I'll test using code with that addition, maybe forcing using the repo head.
I've tested and filed pull request #1046 against branch 1.x that should fix the issue.
Thanks to @luceos for pointing me in the right direction.
Two days that will never come back 😓 Thanks guys, at least you saved my nerves 🫡
thanks @madpilot78 for fixing this, we're currently struggling with this issue on production. Any timeline on when this will be merged and tagged?
composer require pusher/pusher-php-server:7.0.2
Thank you so much! I've been stuck on this issue for days. You are my hero. I consider you from now on one of my closest friends. We're practically family now.
@mpociot since we got this package merge in is there any chance we could make a release for this?
2 days of my life wasted... Thank god I found this page before the weekend.
Thanks to Bvanhaastrecht
2 days of my life wasted... Thank god I found this page before the weekend.
me too 👍
in laravel 9.37 with laravel-websockets 1.13.1 the solutions was downgrading to pusher-php-server 7.0.2 or use the latest pusher-php-server 7.2.1 and manually patch the TriggerEventController from here https://github.com/beyondcode/laravel-websockets/pull/1046/commits/fe78daf914aa5a60d47402b2d0b6390e83c9102a
@bci24 a better fix would be to use "beyondcode/laravel-websockets": "1.x-dev",
in your composer instead of manually patching stuff.
Spent 4 hours debugging the same issue, 4 hours i won't get back. thanks @mankms
Spent the whole day editing configs and changing the composer file to figure out that V7.2 is broken is the source of the problem https://github.com/medilies/trying-laravel-websockets/compare/6f60c31...a5223dd
Now the question is. Should we expect an update soon?
I've downgrade the pusher-php-server and still the client doesn't catch the events abd in the dashboard they didn't appear too
I've ended up switching to soketi
Looking forward to this issue being resolved. Downgrade pusher-php-server to 7.0.2 working for me.
I spent a day, but downgrade to 7.0.2 helped me
Unfortunately i've only found this issue after i've already resolved it by myself. Downgrading to 7.0.2 is the only thing that has worked for me. Can't wait untill it's fixed!
I had the same issue guys been debugging until this afternoon to find this thread, has anyone created a pull request to fix this or should I create one?
A best way to fix:
./vendor/beyondcode/laravel-websockets/src/HttpApi/Controllers/TriggerEventController.php
<?php
namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers;
use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger;
use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger;
use Illuminate\Http\Request;
class TriggerEventController extends Controller
{
public function __invoke(Request $request)
{
$this->ensureValidSignature($request);
$channels = $request->json()->get('channels', []);
$channel = $request->json()->get('channel');
if ($channel) {
$channels[] = $channel;
}
foreach ($channels as $channelName) {
$channel = $this->channelManager->find($request->appId, $channelName);
optional($channel)->broadcastToEveryoneExcept([
'channel' => $channelName,
'event' => $request->json()->get('name'),
'data' => $request->json()->get('data'),
], $request->json()->get('socket_id'));
DashboardLogger::apiMessage(
$request->appId,
$channelName,
$request->json()->get('name'),
$request->json()->get('data')
);
StatisticsLogger::apiMessage($request->appId);
}
return (object) [];
}
}
A best way to fix:
./vendor/beyondcode/laravel-websockets/src/HttpApi/Controllers/TriggerEventController.php
[...]
@kluevandrew You suggested patch looks very similar to mine from #1046, which has already been merged to the 1.x branch.
Unluckily until a new release is cut from 1.x the change is not going to be distributed automatically.
Let's hope a new 1.x release is cut soon.
I still had the issue with v7.2.1 Downgrading to v7.0.2 was working fine for me.
@AliKhedmati
The issue is in beyondcode/laravel-websockets. pusher/pusher-http-php
has changed how it accesses its own API and is not going back, they have no reason too, they do not support servers except their own.
beyondcode/laravel-websockets
needs to adapt to the new way the client accesses the API.
I don't understand why the fix is merged but not a new release being tagged. Is this repo even maintained? @mpociot
A best way to fix:
./vendor/beyondcode/laravel-websockets/src/HttpApi/Controllers/TriggerEventController.php
<?php namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers; use BeyondCode\LaravelWebSockets\Dashboard\DashboardLogger; use BeyondCode\LaravelWebSockets\Facades\StatisticsLogger; use Illuminate\Http\Request; class TriggerEventController extends Controller { public function __invoke(Request $request) { $this->ensureValidSignature($request); $channels = $request->json()->get('channels', []); $channel = $request->json()->get('channel'); if ($channel) { $channels[] = $channel; } foreach ($channels as $channelName) { $channel = $this->channelManager->find($request->appId, $channelName); optional($channel)->broadcastToEveryoneExcept([ 'channel' => $channelName, 'event' => $request->json()->get('name'), 'data' => $request->json()->get('data'), ], $request->json()->get('socket_id')); DashboardLogger::apiMessage( $request->appId, $channelName, $request->json()->get('name'), $request->json()->get('data') ); StatisticsLogger::apiMessage($request->appId); } return (object) []; } }
This worked for me. Glad to find a solution after spending more than a day troubleshooting!
Workaround
composer require pusher/pusher-php-server:7.0.2
You saved my 3 days
"php": "^8.0", "beyondcode/laravel-websockets": "^2.0@beta", "cboden/ratchet": "^0.4.4", "cviebrock/eloquent-sluggable": "^9.0", "fruitcake/laravel-cors": "^2.0.5", "guzzlehttp/guzzle": "^7.7", "illuminate/session": "*", "laravel/framework": "^9.0", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.7", "pusher/pusher-php-server": "7.0.2", I have this version of laravel i think beta 2.o websockets doesnot work for php 8 I also downgrade the pusher from 7.2 to 7.0 but the dashboard of websocj=ket doesnot catch the event
which version of websocket should I use for current versions (but websocket dashboard dosnot catch event) "php": "^8.0", "beyondcode/laravel-websockets": "^2.0@beta", "laravel/framework": "^9.0", "pusher/pusher-php-server": "7.0.2",
I have create full documentation for laravel websocket with realted issue every time. Please check it https://myphpinformation.blogspot.com/2024/01/laravel-websocket-setup-and-example-how-to-use-it.html this my help you.
Hello, after pusher-php-server has been updated to version 7.2 websockets stopped working. I'm using Laravel Echo and the initial connection to private channel is successful, but then I'm not getting any events broadcasted on that channel. With pusher-php-server 7.0.2 everything works fine. Is the new version incompatible with Laravel Websockets and should I wait for an update?