Reconnection code with exponential back-off