The time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection. The default value is 200 ms.
The maximum time to wait for any reconnect attempt (milliseconds). Exponential backoff will not exceed this maximum. The default value is 20 s.
The exponent to use for calculating the next delay time. For example, if the initial time is 200ms and the exponent is 2.0, the next delay will be 400ms, then 800ms, etc. The default value is 2.0.
The maximum time (milliseconds) to allow reconnect attempts to continue without a successful connection, before giving up and abandoning the connection attempt. If zero, the client never gives up. The default value is 0.
The amount of 'jitter' to apply when calculating a delay time, measured in multiples of the initial delay. Jitter is used to reduce the number of simultaneous reconnects that may be issued from multiple clients. The default value is 1.0.
The object with delay parameters, such as delay, maximumRetryTime, etc.
This method sets the exponent to use for calculating the next delay time. For example if the initial time is 200ms and the exponent is 2.0, the next delay will be 400ms, then 800ms, etc.
The exponent to use for calculating the next delay time. For example, if the initial time is 200ms and the exponent is 2.0, the next delay will be 400ms, then 800ms, etc.
The ExponentialDelayStrategy object.
This method returns the time (in milliseconds) that the client should delay before connecting to the given server URI.
The URI of the server.
The time (in milliseconds) that the client should delay.
This method sets the time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection.
The time (in milliseconds) to wait before reconnecting to a server for the first time after a failed connection.
The Delay object.
This method sets the jitter factor used to add randomness to the delay time. Jitter is represented as a multiple
of the initial delay time;
a random number from [ 0, (JITTER * INITIAL_DELAY) )
is added to nonzero time delays.
The amount of 'jitter' to apply when calculating a delay time, measured in multiples of the initial delay. Jitter is used to reduce the number of simultaneous reconnects that may be issued from multiple clients.
The ExponentialDelayStrategy object.
This method sets the maximum time to wait between any reconnection attempts. Exponential backoff will not exceed this maximum.
The maximum time to wait for any reconnect attempt (milliseconds). Exponential backoff will not exceed this maximum.
The ExponentialDelayStrategy object.
This method sets the time (in milliseconds) to allow reconnect attempts to continue without a successful connection, before "giving up" and abandoning the connection attempt. 0 means never give up.
The maximum time (milliseconds) to allow reconnect attempts to continue without a successful connection, before giving up and abandoning the connection attempt. If zero, the client never gives up.
The ExponentialDelayStrategy object.
This method resets the state of this reconnect delay. AMPS calls this method when a connection is established.
ExponentialDelayStrategy is an implementation that exponentially backs off when reconnecting to the same server, with a maximum time to retry before it gives up entirely.
Create the strategy with all default values:
const strategy = new ExponentialDelayStrategy();
Set jitter to 3.5, and keep other parameters default:
const strategy = new ExponentialDelayStrategy({jitter: 3.5});
Set all params as arguments ...
const strategy = new ExponentialDelayStrategy(400, 25000, 1.5, 0, 2.5);
... or using the object with values ...
const strategy = new ExponentialDelayStrategy({ initialDelay: 400, maximumDelay: 25000, backoffExponent: 1.5, maximumRetryTime: 0, jitter: 2.5 });
... or using setter methods:
const strategy = new ExponentialDelayStrategy() .initialDelay(400) .maximumDelay(25000) .backoffExponent(1.5) .maximumRetryTime(0) .jitter(2.5);
Setter methods can also be used after initialization of the strategy to change values dynamically.