Add retrying mechanism into the connection