'PubNub unsubscribe slows down the whole web application

I noticed my JS app gets slow sometimes (all UI gets slow). I tried to figure out why and I noticed that PUBNUB unsubscribe event is really heavy. All other PUBNUB events, such as state, subscribe work well.

It should be async, I know, but even being async it slows down the whole app, even when it's very simple.

I use pubnub presence.

Chrome Profile

Do you know is that happening? Is that a pubnub bug? And how to improve it's performance.



Solution 1:[1]

[UPDATE: Self-serve property configuration is possible] You can enable the "generate leave on disconnect" property for your PubNub Key Set

  1. login to your PN account
  2. select your key set (sub/pub keys)
  3. under PRESENCE, Generate Leave on TCP Fin or RST property can be enabled or disabled

PRESENCE gen leave config

Enabled means that when the client drops the connection, PN server will interpret the TCP FIN (or RST) signal as a leave event.

Disabled means no leave presence event is generated and eventually a timeout presence event will be generated for that client (UUID) for each channel they were previously subscribed to

An explicit unsubscribe call by the client always results in leave presence events being generated for each of the channels that was in that call.

NOTE: Be sure to test your app thoroughly when you change this property. It would seem to be having this property enabled is always the best option but it may have unexpected behaviors depending on your implementation.

See docs for more details about how PubNub Presence works

For any questions, please contact [email protected] with details to get further insights.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1