Added automatic reconnection try when losing connection.