pusher / pusher-http-php

PHP library for interacting with the Pusher Channels HTTP API
https://pusher.com/docs/server_api_guide
1.4k stars 306 forks source link

Compatibility issues with ugprade 7.0.2 -> 7.2.0 #351

Closed adriangornypl closed 1 year ago

adriangornypl commented 1 year ago

After upgrading pusher from version 7.0.2 to 7.2.0 we stopped receiving messages on private channels. Our stack uses laravel 8.x (v8.83.25) and laravel-echo with pusher-js on frontend.

The weirdest part is that we did not made any change to the broadcasting code, we broadcast data on private channels to subscribed users with json data. Connection is being made to the back-end, authorization is successful, subscription is created but messages are not being sent anymore.

Example broadcast class:

class BuildStatusUpdated implements ShouldBroadcastNow
{
    private SomeModel $model;

    public function __construct(SomeModel $model)
    {
        $this->model = $model;
    }

    public function broadcastOn()
    {
        return new PrivateChannel('App.Model.'.$this->model->uuid);
    }

    public function broadcastAs(): string
    {
        return 'model.updated.buildstatus';
    }

    public function broadcastWith(): array
    {
        return [
            'uuid' => $this->model->uuid
        ];
    }
}

Frontend subscription code (relevant part):

Echo.private(`App.Model.${modelUuid}`).listen(
      ".model.updated.buildstatus",
      callback
    )
Peter-Fogarty commented 1 year ago

I had the same issue. Spent three days poking around to figure out why everything stopped working, then rolled back to 7.0.2 and it all works again.

madpilot78 commented 1 year ago

I'm also seeing the same issue with a similar laravel setup.

egbavou commented 1 year ago

I had the same issue. I setup laravel websocket using pusher php server version 7.2.0 and event it's not fire. I am able to connect to channel.

madpilot78 commented 1 year ago

Ti provide further information, I'm using beyondcode/laravel-websockets as a server for my push notifications, not the official pusher service.

The code there does handle both channel and channels though:

https://github.com/beyondcode/laravel-websockets/blob/1f25913ce05c66bbff1f925106bf9490ec0eb3bf/src/API/TriggerEvent.php#L19

It would be useful if other people experiencing the issue, reported which backend server they are using.

adriangornypl commented 1 year ago

That is correct, these are the project dependencies:

        "beyondcode/laravel-websockets": "^1.9",
        "pusher/pusher-php-server": "7.2.0",
egbavou commented 1 year ago

Thank you. I want to use redis like queue system. Did you know right config for this ??

egbavou commented 1 year ago

Thank you for your response. I make it work fine now using : "pusher/pusher-php-server": "7.0.2"

madpilot78 commented 1 year ago

https://github.com/beyondcode/laravel-websockets/blob/1f25913ce05c66bbff1f925106bf9490ec0eb3bf/src/API/TriggerEvent.php#L19

Regarding this piece of code, @luceos in https://github.com/beyondcode/laravel-websockets/issues/1041#issuecomment-1278551404 pointed out that this code was merged a few days ago and is not present in any release, so he most probably is right and that change is breaking things for us.

I'm going to test using more recent beyondcode/laravel-websocket code from their repo later today.

egbavou commented 1 year ago

OK @madpilot78 keep us inform

benjamin-tang-pusher commented 1 year ago

If this was caused by another library, could this issue be moved there? This doesn't look like an issue on Pusher's side.

madpilot78 commented 1 year ago

@benjamin-tang-pusher I've opened the pull request with the beyondcode/laravel-websockets project at beyondcode/laravel-websockets#1046

There's also an issue opened there:beyondcode/laravel-websockets#1041

I think this one can be closed, and discussion proceed there.