Reconnection policies allow the DataStax drivers to automatically reestablish a connection to a node that was previously marked as down.
A node can be marked down by the server’s gossip process or as a result of an idle connection timeout. Status changes are passed along the control connection back to the driver.
All of the drivers offer a standard reconnection policy. Some drivers offer additional reconnection policies:
Constant: The driver waits a constant amount of time between each reconnection attempt.
Exponential: The driver waits exponentially longer between each reconnection attempt.
Fixed: The driver waits a different amount of time between each reconnection attempt.
Drivers that offer the exponential reconnection policy use that policy as their default. For other drivers, the constant reconnection policy is the default policy.
The control connection for the drivers listens to push notifications from the DSE server cluster. When a node is marked up, all scheduled reconnections are canceled and a new connection to that node is established.
To prevent intermediate network devices like routers and firewalls from disconnecting the drivers from a node, an OPTIONS request is sent to a connection at a constant interval, also known as a heartbeat. If the connection becomes idle and the node does not respond to the heartbeat in a given amount of time, the node is marked down. Once this occurs, the driver waits a specified amount of time based on the reconnection policy before attempting to reconnect to the node.