Implement automatic reconnect. Reconnection is implemented by trying and
waiting for 3 seconds, for a maximum of 10 times.