Add retry mechanism for reconnecting