**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/main/java/org/elasticsearch/transport/ProxyConnectionStrategy.java
}
        }), Setting.Property.Dynamic, Setting.Property.NodeScope)
    );
    /**
     * The maximum number of socket connections that will be established to a remote cluster. The default is 18.
     */
    public static final Setting.AffixSetting<Integer> REMOTE_SOCKET_CONNECTIONS = Setting.affixKeySetting(
        "cluster.remote.",
        "proxy_socket_connections",
        (ns, key) -> intSetting(
            key,
            18,
            1,
            new StrategyValidator<>(ns, key, ConnectionStrategy.PROXY),
            Setting.Property.Dynamic,
            Setting.Property.NodeScope
        )
    );
    /**
     * A configurable server_name attribute
     */
    public static final Setting.AffixSetting<String> SERVER_NAME = Setting.affixKeySetting(
        "cluster.remote.",
        "server_name",
        (ns, key) -> Setting.simpleString(
            key,
            new StrategyValidator<>(ns, key, ConnectionStrategy.PROXY),
            Setting.Property.Dynamic,
            Setting.Property.NodeScope
        )