Not necessarily, since PubNub detects a leave event when an outstanding http request is closed (i.e. not when a connection is closed). To ensure a leave event triggers, the client can issue a new subscribe request just prior to disconnecting from the channel. In general, join and leave events work as follows:
- A
joinevent triggers when the first subscribe http request completes (typically with timetoken 0) which returns immediately with the current timetoken. Subscribing with timetoken > 1000 will block until the first message is received on that channel and then thejoinevent triggers. - PubNub servers don't always notice a network loss or other non-graceful disconnects, hence no
leaveevent is fired. Instead, atimeoutevent is fired after the 320 second period is elapsed.