How do I attempt to reconnect to PubNub after the auto-reconnect cycle is exhausted?

Normally, the subscribe loop automatically recovers by attempting to reconnect a pre-configured number of times at given intervals. At the end of this loop, if all attempts to establish a network connection failed, the disconnect callback is invoked. To manually attempt a reconnect, override the disconnect callback using the following:

  1. Check that the network is currently available by making a Pubnub time call
  2. Call disconnectAndResubscribe() in the successCallback of the time call

NOTE: disconnectAndResubscribe invokes error callbacks on all channels. Hence it cannot be used in error callback since this will create recursion and can lead to stack overflow.