- Laravel6
- lighthouse-php5
I'm using lighthouse-php for GraphQL Subscription and I receive the message from pusher.
So I have the question of Subscription unsubscribe.
server side => pusher => front side
Documantation this part means just stop pusher => front side. If I don't remove the redis, still server side working and push message to pusher, right?
unsubscribeFromChannel(subscriptionChannel) {
this.pusher.unsubscribe(subscriptionChannel);
}
I want to stop server side => pusher too. What options I have?
thanks
This is documented in the Lighthouse documentation, a direct link here: https://lighthouse-php.com/5/subscriptions/getting-started.html#expiring-subscriptions.
But also some snippets here just in case it helps.
So setting this
.env
variable is a great way to expire subscriptions that are left behind automatically, do set this timeout large enough, if you have a lot of long running subscriptions an hour might not be enough.But since you are using Pusher there is a faster way to cleanup the subscriptions:
This webhook (channel existence webhook as Pusher calls them) will remove subscriptions for channels that are vacated (no subscribers left) this will happen a few seconds after the user disconnects keeping the subscriptions in Redis up-to-date.
So long story short, setup a TTL for the subscriptions as a fallback and configure the Pusher webhook for your app. This will keep the subscriptions stored up-to-date and prevent unneeded work.