How to use RabbitMQ list of hosts connection parameter
<p>I'm trying to use the <code>IList&lt;string&gt;</code> parameter when creating a connection in the C# rabbitMQ library:</p>

<p><a href="https://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.6.1/rabbitmq-dotnet-client-3.6.1-client-htmldoc/html/type-RabbitMQ.Client.ConnectionFactory.html#method-M:RabbitMQ.Client.ConnectionFactory.CreateConnection(System.Collections.Generic.IList%7BSystem.String%7D)" rel="nofollow">IConnection CreateConnection(IList hostnames)</a></p>

<p>My code is as follows:</p>

<pre><code>    private IConnection CreateConnection()
    {
        var connectionFactory = new ConnectionFactory
        {
            UserName = _userName,
            Password = _password,
            VirtualHost = _vhost,
            AutomaticRecoveryEnabled = DEFAULT_AUTO_RECOVER,
            RequestedHeartbeat = HEARTBEAT_TIMEOUT_SECONDS,
            Port = AmqpTcpEndpoint.UseDefaultPort,
        };
        // _hosts contains valid IPs "###.###.###.###"
        return connectionFactory.CreateConnection(_hosts);
    }
</code></pre>

<p>But regardless of what I suppose for the <code>hosts</code> parameter it doesn't seem to connect (I get "None of the specified endpoints were reachable")</p>

<p>Even if my list contains only one element.</p>

<p>Now, if I use the <strong>single</strong> host implementation like this, it works correctly:</p>

<pre><code>    private IConnection CreateConnection()
    {
        var connectionFactory = new ConnectionFactory
        {
            UserName = _userName,
            Password = _password,
            VirtualHost = _vhost,
            AutomaticRecoveryEnabled = DEFAULT_AUTO_RECOVER,
            RequestedHeartbeat = HEARTBEAT_TIMEOUT_SECONDS,
            Port = AmqpTcpEndpoint.UseDefaultPort,
            HostName = _hosts.First() // or just one string
        };
        return connectionFactory.CreateConnection();
    }
</code></pre>

<p>I recognize that RabbitMQ suggests not storing the set of hosts on the client but I'm just trying to get their provided method to work.</p>