**Build scan:**
https://gradle-enterprise.elastic.co/s/4jzcubi7fi7fk/tests/:server:test/org.elasticsearch.transport.ProxyConnectionStrategyTests/testProxyStrategyWillResolveAddressesEachConnect

**Reproduction line:**
```
./gradlew ':server:test' --tests "org.elasticsearch.transport.ProxyConnectionStrategyTests.testProxyStrategyWillResolveAddressesEachConnect" -Dtests.seed=EA553A058C9E39DA -Dtests.locale=de-AT -Dtests.timezone=America/Maceio -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
No

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.transport.ProxyConnectionStrategyTests&tests.test=testProxyStrategyWillResolveAddressesEachConnect

**Failure excerpt:**
```
com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=2052, name=elasticsearch[org.elasticsearch.transport.ProxyConnectionStrategyTests][management][T#1], state=RUNNABLE, group=TGRP-ProxyConnectionStrategyTests]

  at __randomizedtesting.SeedInfo.seed([EA553A058C9E39DA:2A656647652A147E]:0)

  Caused by: java.lang.AssertionError: should not happen since onFailure should catch it and report with underlying cause

    at __randomizedtesting.SeedInfo.seed([EA553A058C9E39DA]:0)
    at org.elasticsearch.transport.ProxyConnectionStrategy.openConnections(ProxyConnectionStrategy.java:320)
    at org.elasticsearch.transport.ProxyConnectionStrategy$1.onFailure(ProxyConnectionStrategy.java:282)
    at org.elasticsearch.transport.ProxyConnectionStrategy.lambda$openConnections$10(ProxyConnectionStrategy.java:314)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.acceptException(ActionListenerImplementations.java:186)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.onFailure(ActionListenerImplementations.java:191)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onFailure(ContextPreservingActionListener.java:39)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNodeOrRetry(ClusterConnectionManager.java:140)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNode(ClusterConnectionManager.java:111)
    at org.elasticsearch.transport.RemoteConnectionManager.connectToRemoteClusterNode(RemoteConnectionManager.java:73)
    at org.elasticsearch.transport.ProxyConnectionStrategy.openConnections(ProxyConnectionStrategy.java:309)
    at org.elasticsearch.transport.ProxyConnectionStrategy$1.onFailure(ProxyConnectionStrategy.java:282)
    at org.elasticsearch.transport.ProxyConnectionStrategy.lambda$openConnections$10(ProxyConnectionStrategy.java:314)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.acceptException(ActionListenerImplementations.java:186)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.onFailure(ActionListenerImplementations.java:191)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onFailure(ContextPreservingActionListener.java:39)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNodeOrRetry(ClusterConnectionManager.java:140)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNode(ClusterConnectionManager.java:111)
    at org.elasticsearch.transport.RemoteConnectionManager.connectToRemoteClusterNode(RemoteConnectionManager.java:73)
    at org.elasticsearch.transport.ProxyConnectionStrategy.openConnections(ProxyConnectionStrategy.java:309)
    at org.elasticsearch.transport.ProxyConnectionStrategy$1.onFailure(ProxyConnectionStrategy.java:282)
    at org.elasticsearch.transport.ProxyConnectionStrategy.lambda$openConnections$10(ProxyConnectionStrategy.java:314)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.acceptException(ActionListenerImplementations.java:186)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations$DelegatingResponseActionListener.onFailure(ActionListenerImplementations.java:191)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.ActionListenerImplementations.safeAcceptException(ActionListenerImplementations.java:62)
    at org.elasticsearch.action.ActionListenerImplementations.safeOnFailure(ActionListenerImplementations.java:73)
    at org.elasticsearch.action.DelegatingActionListener.onFailure(DelegatingActionListener.java:27)
    at org.elasticsearch.action.support.ContextPreservingActionListener.onFailure(ContextPreservingActionListener.java:39)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNodeOrRetry(ClusterConnectionManager.java:140)
    at org.elasticsearch.transport.ClusterConnectionManager.connectToNode(ClusterConnectionManager.java:111)
    at org.elasticsearch.transport.RemoteConnectionManager.connectToRemoteClusterNode(RemoteConnectionManager.java:73)
    at org.elasticsearch.transport.ProxyConnectionStrategy.openConnections(ProxyConnectionStrategy.java:309)
    at org.elasticsearch.transport.ProxyConnectionStrategy.performProxyConnectionProcess(ProxyConnectionStrategy.java:241)
    at org.elasticsearch.transport.ProxyConnectionStrategy.connectImpl(ProxyConnectionStrategy.java:232)
    at org.elasticsearch.transport.RemoteConnectionStrategy$1.doRun(RemoteConnectionStrategy.java:296)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
    at java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:916)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.lang.Thread.run(Thread.java:1623)

```
server/src/test/java/org/elasticsearch/transport/ProxyConnectionStrategyTests.java
import org.elasticsearch.core.Strings;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TransportVersionUtils;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.hamcrest.Matchers.instanceOf;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.spy;
public class ProxyConnectionStrategyTests extends ESTestCase {
    private final String clusterAlias = "cluster-alias";
    private final String modeKey = RemoteConnectionStrategy.REMOTE_CONNECTION_MODE.getConcreteSettingForNamespace(clusterAlias).getKey();
    private final Settings settings = Settings.builder().put(modeKey, "proxy").build();
    private final ConnectionProfile profile = RemoteConnectionStrategy.buildConnectionProfile("cluster", settings, false);