loop with a connection timeout for direct connections.