uber simple reconnect logic for
The process of reconnecting a client should be smarter than just re-trying the same server repeatedly. A client should attempt to round-robin connection attempts to a series of servers running on different subnets (or at least in different data centers) and exponentially back off from connections that fail.
var restream = require'restream';var options =reconnectTime: 128 // time before attempting to reconnectconnectTime: 1024 // max time spent attempting to connectservers:port: 9960 host: '192.0.0.2'port: 9968 host: '126.96.36.199'port: 9020 host: '188.8.131.52'port: 9967 host: '184.108.40.206'var client = restreamconnectoptionsclienton'connect'// ...connected, event may occur many times.clienton'error'// ...could not connect to a specific server.clienton'fail'// ...could not connect to any servers.
The options object also accepts the regular options that are accepted by the
tls.connect andtcp.connect` methods. Method returns an event emitter.
Specify if something other than
tcp should be used.
An optional number to determine how long before attempting the next
3e4. Note that this number is multiplied by the number of
failures to connect.
An optional number to determine how long before a simple connection attempt should be timed out.
An array that contains a list of servers. Each object in the array should
host address. When a connection can't be made to a
server, the next server in the array is selected for the reconnect attempt.
How many times to cycle though the start list before calling the