-
Notifications
You must be signed in to change notification settings - Fork 128
Reconnection
Daniel Rhodes edited this page Mar 3, 2016
·
3 revisions
In some scenarios you will want to manipulate the client's approach to reconnecting with the server if the connection flaps.
Several options are available:
- Exponential Backoff
self.client.reconnectionStrategy = .ExponentialBackoff(maxRetries: 30, maxIntervalTime: 10)
- Logarithmic Backoff
self.client.reconnectionStrategy = .LogarithmicBackoff(maxRetries: 30, maxIntervalTime: 10)
- Linear
self.client.reconnectionStrategy = .Linear(maxRetries: 30, maxIntervalTime: 10)
- None
self.client.reconnectionStrategy = .None
maxIntervalTime
in this case is the maximum time interval between requests.
If you have defined a reconnectionStrategy
, then you can also be notified when a reconnection is about to occur and cancel this attempt, as shown below:
self.client.willReconnect = {
if (someConditionToNotReconnect) {
return false
}
return true
}