Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presence channel not unsubscribing after refresh #92

Open
nikhilSriva opened this issue Apr 3, 2022 · 3 comments
Open

Presence channel not unsubscribing after refresh #92

nikhilSriva opened this issue Apr 3, 2022 · 3 comments

Comments

@nikhilSriva
Copy link

Hi,
After refreshing a react app, the presence channel subscription/ unsubscription is not working. No API calls are executed.

   "pubnub": "^5.0.1",
   "pubnub-react": "^2.1.1",

How do I resolve this?

@elvis-pn
Copy link
Contributor

Without seeing your code it's hard to now exactly. Without seeing anything I would suggest ensuring any places where you subscribe in a useEffect you return a cleanup function that unsubscribes.

What do you mean by the presence channel subscription is not working? Are you not receiving events or are you not seeing the user leave the channel.

@talksik
Copy link

talksik commented Jul 18, 2022

same problem here. It seems like after the refresh and some time later upon joining the same channels again, the time out triggers while this client is on the app.

  1. load page
  2. joing bunch of channels freely
  3. unsubscribe and do cleanup in unmount & refresh the page
  4. client joins all of the channels again
  5. eventually, a lot of times (not consistent), the timeout event even will trigger randomly now

I'm thinking of going back to the older SDK. any thoughts on that? I feel like it may be more stable?

@elvis-pn
Copy link
Contributor

I am not inclined to think this is related to the version bump, but that could be a valuable debugging step just to confirm.

How long is there between client leaving and joining channels? If it is less than 2 seconds (the default value of the Debounce setting in your admin console) this could cause some weirdness, though it still doesn't explain this issue. I would suggest using dev tools to capture network traffic around when you unsubscribe and cleanup to see if an explicit "leave" event is being sent.

If not. ensure you have not set suppressLeaveEvents to true in the SDK config. If you are still not seeing leave events in the network requests, that will help us identify where the issue is.

As a quick fix, enabling Generate Leave on TCP FIN or RST in the admin console may resolve your issue as reloading the page should end any ongoing connections and generate a leave event through this method immediately.

Let me know if any of that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants