Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Triggering event using pusher does not work consistently when using replication #777

Closed
mdprotacio opened this issue Jun 3, 2021 · 4 comments

Comments

@mdprotacio
Copy link
Contributor

We have been trying to use replication using async-redis driver on multiple ec2 instances and served through application load balancer and using CloudFront.

We have some backend services that triggers some event notifications using pusher-php-server which does not subscribe to channel but instead just trigger an event on the channel.

The problem appears to be on how the message is propagated across servers. For instance, the enduser subscribes on server1 and thus registers the channel on the LocalChannelManager but does not register the same channel on server2. The backend service now triggers an event on server2. However, since the LocalChannelManager instance does not have the channel on server2, the call to broadcastToEveryoneExcept on PusherClientMessage class will not succeed as channel is not defined in that server2.

As a workaround, we have overriden the find method of RedisChannelManager to return an instance of channel by updating the local property as if the channel is registered when not present.

Despite of doing that workaround, it doesn't appear to be working well consistently until we use sticky sessions on target group. It appears that the implementation of pubsub should be reviewed/redesigned to ensure that the message is sent across all instances regardless of where the request is received.

@mdprotacio
Copy link
Contributor Author

When the trigger is received on server2 but no clients have subscribed on server2 yet and instead subscribed through server1, the channel is non existent on server2, making the optional($channel) not triggered due to channelManager->find returning null on server2.

Screen Shot 2021-06-03 at 11 01 27 AM

@mdprotacio
Copy link
Contributor Author

When multiple connections are subscribed to a channel and the browser is refreshed triggering unsubscription from one connection, the single connection triggers removal of the channel from set when others are still connected to the channel.

Screen Shot 2021-06-03 at 12 26 45 PM

@mdprotacio
Copy link
Contributor Author

Should be addressed in #778

@MahdiBagheri71
Copy link

in file :

vendor\beyondcode\laravel-websockets\src\WebSockets\Messages\PusherClientMessage.php

add code :
$this->connection->send(json_encode($this->payload));//By Mahdi for send Message :)

@mpociot mpociot closed this as completed Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants