title: Why does HornetQConnectionFactory client not do automatic failover?
body: <p>I have clustered two wildfly9 servers, I want to use load-balancing and failover JMS feature in domain mode, config as below:</p>
  <p><strong>master ip</strong>: 192.168.1.1<br />
  <strong>slave ip</strong>:  192.168.1.2<br />
  <strong>hornetq ver 2.4.7</strong><br />
  <strong>wildfly 9</strong></p>
  <p>During while loop (send dummy msg) failover occurs on master, client connection does switch to slave and throws exception, why?</p>
  <pre><code>&lt;hornetq-server&gt;
                      &lt;clustered&gt;true&lt;/clustered&gt;
                      &lt;cluster-password&gt;my-pass&lt;/cluster-password&gt;
                      &lt;allow-failback&gt;true&lt;/allow-failback&gt;
                      &lt;failover-on-shutdown&gt;true&lt;/failover-on-shutdown&gt;
                      &lt;shared-store&gt;false&lt;/shared-store&gt;
                      &lt;journal-file-size&gt;102400&lt;/journal-file-size&gt;
  
                      &lt;connectors&gt;
                          &lt;netty-connector name=&quot;netty&quot; socket-binding=&quot;messaging&quot;/&gt;
                          &lt;netty-connector name=&quot;netty-throughput&quot; socket-binding=&quot;messaging-throughput&quot;&gt;
                              &lt;param key=&quot;batch-delay&quot; value=&quot;50&quot;/&gt;
                          &lt;/netty-connector&gt;
                          &lt;in-vm-connector name=&quot;in-vm&quot; server-id=&quot;0&quot;/&gt;
                          &lt;connector name=&quot;node1&quot;&gt;
                              &lt;param key=&quot;host&quot; value=&quot;192.168.1.2&quot;/&gt;
                              &lt;param key=&quot;port&quot; value=&quot;5445&quot;/&gt;
                              &lt;factory-class&gt;org.hornetq.core.remoting.impl.netty.NettyConnectorFactory&lt;/factory-class&gt;
                          &lt;/connector&gt;
                      &lt;/connectors&gt;
  &lt;acceptors&gt;
                          &lt;netty-acceptor name=&quot;netty&quot; socket-binding=&quot;messaging&quot;/&gt;
                          &lt;netty-acceptor name=&quot;netty-throughput&quot; socket-binding=&quot;messaging-throughput&quot;&gt;
                              &lt;param key=&quot;batch-delay&quot; value=&quot;50&quot;/&gt;
                              &lt;param key=&quot;direct-deliver&quot; value=&quot;false&quot;/&gt;
                          &lt;/netty-acceptor&gt;
                          &lt;in-vm-acceptor name=&quot;in-vm&quot; server-id=&quot;0&quot;/&gt;
                      &lt;/acceptors&gt;
  
                      &lt;cluster-connections&gt;
                          &lt;cluster-connection name=&quot;my-cluster&quot;&gt;
                              &lt;address&gt;jms&lt;/address&gt;
                              &lt;connector-ref&gt;netty&lt;/connector-ref&gt;
                              &lt;check-period&gt;1000&lt;/check-period&gt;
                              &lt;connection-ttl&gt;1000&lt;/connection-ttl&gt;
                              &lt;reconnect-attempts&gt;3&lt;/reconnect-attempts&gt;
                              &lt;static-connectors&gt;
                                  &lt;connector-ref&gt;
                                      node1
                                  &lt;/connector-ref&gt;
                              &lt;/static-connectors&gt;
                          &lt;/cluster-connection&gt;
                      &lt;/cluster-connections&gt;
  
                      &lt;security-settings&gt;
                          &lt;security-setting match=&quot;#&quot;&gt;
                              &lt;permission type=&quot;send&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;consume&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;createNonDurableQueue&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;deleteNonDurableQueue&quot; roles=&quot;guest&quot;/&gt;
                          &lt;/security-setting&gt;
                      &lt;/security-settings&gt;
  
  &lt;address-settings&gt;
                          &lt;address-setting match=&quot;#&quot;&gt;
                              &lt;dead-letter-address&gt;jms.queue.DLQ&lt;/dead-letter-address&gt;
                              &lt;expiry-address&gt;jms.queue.ExpiryQueue&lt;/expiry-address&gt;
                              &lt;max-size-bytes&gt;10485760&lt;/max-size-bytes&gt;
                              &lt;page-size-bytes&gt;2097152&lt;/page-size-bytes&gt;
                              &lt;message-counter-history-day-limit&gt;10&lt;/message-counter-history-day-limit&gt;
                              &lt;redistribution-delay&gt;1000&lt;/redistribution-delay&gt;
                          &lt;/address-setting&gt;
                      &lt;/address-settings&gt;
  
                      &lt;jms-connection-factories&gt;
                          &lt;connection-factory name=&quot;InVmConnectionFactory&quot;&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;in-vm&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:/ConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                          &lt;/connection-factory&gt;
                          &lt;connection-factory name=&quot;RemoteConnectionFactory&quot;&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;netty&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:jboss/exported/jms/RemoteConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                              &lt;ha&gt;true&lt;/ha&gt;
  &lt;block-on-durable-send&gt;true&lt;/block-on-durable-send&gt;
  &lt;block-on-acknowledge&gt;true&lt;/block-on-acknowledge&gt;
  &lt;connection-ttl&gt;600000&lt;/connection-ttl&gt;
  &lt;call-timeout&gt;180000&lt;/call-timeout&gt;
  &lt;client-failure-check-period&gt;60000&lt;/client-failure-check-period&gt;
  &lt;block-on-non-durable-send&gt;true&lt;/block-on-non-durable-send&gt;
  &lt;retry-interval&gt;4000&lt;/retry-interval&gt;
  &lt;reconnect-attempts&gt;5&lt;/reconnect-attempts&gt;
  &lt;confirmation-window-size&gt;1000000&lt;/confirmation-window-size&gt;
  &lt;consumer-window-size&gt;3145728&lt;/consumer-window-size&gt;
  
                          &lt;/connection-factory&gt;
                          &lt;pooled-connection-factory name=&quot;hornetq-ra&quot;&gt;
                              &lt;transaction mode=&quot;xa&quot;/&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;in-vm&quot;/&gt;
                                  &lt;connector-ref connector-name=&quot;node1&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:/JmsXA&quot;/&gt;
                                  &lt;entry name=&quot;java:jboss/DefaultJMSConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                              &lt;ha&gt;true&lt;/ha&gt;
                              &lt;block-on-acknowledge&gt;true&lt;/block-on-acknowledge&gt;
                              &lt;reconnect-attempts&gt;-1&lt;/reconnect-attempts&gt;
                          &lt;/pooled-connection-factory&gt;
                      &lt;/jms-connection-factories&gt;
  </code></pre>
  <p>slave configuration as below:</p>
  <pre><code> &lt;hornetq-server&gt;
                      &lt;clustered&gt;true&lt;/clustered&gt;
                      &lt;cluster-password&gt;my-pass&lt;/cluster-password&gt;
                      &lt;shared-store&gt;false&lt;/shared-store&gt;
                      &lt;journal-file-size&gt;102400&lt;/journal-file-size&gt;
                      &lt;allow-failback&gt;true&lt;/allow-failback&gt;
                      &lt;failover-on-shutdown&gt;true&lt;/failover-on-shutdown&gt;
                      &lt;backup&gt;true&lt;/backup&gt;
                      &lt;connectors&gt;
                         &lt;netty-connector name=&quot;netty&quot; socket-binding=&quot;messaging&quot;/&gt;
                         &lt;netty-connector name=&quot;netty-throughput&quot; socket-binding=&quot;messaging-throughput&quot;&gt;
                           &lt;param key=&quot;batch-delay&quot; value=&quot;50&quot;/&gt;
                          &lt;/netty-connector&gt;
                          &lt;in-vm-connector name=&quot;in-vm&quot; server-id=&quot;1&quot;/&gt;
                          &lt;connector name=&quot;node-master&quot;&gt;
                             &lt;factory-class&gt;org.hornetq.core.remoting.impl.netty.NettyConnectorFactory&lt;/factory-class&gt;
                             &lt;param key=&quot;host&quot; value=&quot;192.168.1.1&quot;/&gt;
                            &lt;param key=&quot;port&quot; value=&quot;5445&quot;/&gt;
                          &lt;/connector&gt;
                      &lt;/connectors&gt;
  &lt;acceptors&gt;
                         &lt;netty-acceptor name=&quot;netty&quot; socket-binding=&quot;messaging&quot;/&gt;
                         &lt;netty-acceptor name=&quot;netty-throughput&quot; socket-binding=&quot;messaging-throughput&quot;&gt;
                           &lt;param key=&quot;batch-delay&quot; value=&quot;50&quot;/&gt;
                           &lt;param key=&quot;direct-deliver&quot; value=&quot;false&quot;/&gt;
                         &lt;/netty-acceptor&gt;
                         &lt;in-vm-acceptor name=&quot;in-vm&quot; server-id=&quot;1&quot;/&gt;
                       &lt;/acceptors&gt;
  
                      &lt;cluster-connections&gt;
                          &lt;cluster-connection name=&quot;my-cluster&quot;&gt;
                              &lt;address&gt;jms&lt;/address&gt;
                              &lt;connector-ref&gt;netty&lt;/connector-ref&gt;
                              &lt;reconnect-attempts&gt;3&lt;/reconnect-attempts&gt;
                              &lt;connection-ttl&gt;1000&lt;/connection-ttl&gt;
                              &lt;check-period&gt;1000&lt;/check-period&gt;
                              &lt;static-connectors&gt;
                                  &lt;connector-ref&gt;node-master&lt;/connector-ref&gt;
                              &lt;/static-connectors&gt;
                          &lt;/cluster-connection&gt;
                      &lt;/cluster-connections&gt;
                      &lt;security-settings&gt;
                          &lt;security-setting match=&quot;#&quot;&gt;
                              &lt;permission type=&quot;send&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;consume&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;createNonDurableQueue&quot; roles=&quot;guest&quot;/&gt;
                              &lt;permission type=&quot;deleteNonDurableQueue&quot; roles=&quot;guest&quot;/&gt;
                          &lt;/security-setting&gt;
                      &lt;/security-settings&gt;
  
   &lt;/address-settings&gt;
                      &lt;jms-connection-factories&gt;
                          &lt;connection-factory name=&quot;InVmConnectionFactory&quot;&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;in-vm&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:/ConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                          &lt;/connection-factory&gt;
                          &lt;connection-factory name=&quot;RemoteConnectionFactory&quot;&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;netty&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:jboss/exported/jms/RemoteConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                              &lt;block-on-acknowledge&gt;true&lt;/block-on-acknowledge&gt;
                               &lt;ha&gt;true&lt;/ha&gt;
  &lt;block-on-durable-send&gt;true&lt;/block-on-durable-send&gt;
  &lt;block-on-acknowledge&gt;true&lt;/block-on-acknowledge&gt;
  &lt;connection-ttl&gt;600000&lt;/connection-ttl&gt;
  &lt;call-timeout&gt;180000&lt;/call-timeout&gt;
  &lt;client-failure-check-period&gt;60000&lt;/client-failure-check-period&gt;
  &lt;block-on-non-durable-send&gt;true&lt;/block-on-non-durable-send&gt;
  &lt;retry-interval&gt;4000&lt;/retry-interval&gt;
  &lt;reconnect-attempts&gt;5&lt;/reconnect-attempts&gt;
  &lt;confirmation-window-size&gt;1000000&lt;/confirmation-window-size&gt;
  &lt;consumer-window-size&gt;3145728&lt;/consumer-window-size&gt;
  
                          &lt;/connection-factory&gt;
  
   &lt;pooled-connection-factory name=&quot;hornetq-ra&quot;&gt;
                              &lt;transaction mode=&quot;xa&quot;/&gt;
                              &lt;connectors&gt;
                                  &lt;connector-ref connector-name=&quot;in-vm&quot;/&gt;
                                  &lt;connector-ref connector-name=&quot;node-master&quot;/&gt;
                              &lt;/connectors&gt;
                              &lt;entries&gt;
                                  &lt;entry name=&quot;java:/JmsXA&quot;/&gt;
                                  &lt;!-- Global JNDI entry used to provide a default JMS Connection factory to EE application --&gt;
                                  &lt;entry name=&quot;java:jboss/DefaultJMSConnectionFactory&quot;/&gt;
                              &lt;/entries&gt;
                              &lt;ha&gt;true&lt;/ha&gt;
                              &lt;block-on-acknowledge&gt;true&lt;/block-on-acknowledge&gt;
                              &lt;reconnect-attempts&gt;-1&lt;/reconnect-attempts&gt;
                          &lt;/pooled-connection-factory&gt;
                      &lt;/jms-connection-factories&gt;
  </code></pre>
  <p>my client code as below:</p>
  <pre><code> Map&lt;String, Object&gt; connectionParams = new HashMap&lt;String, Object&gt;();
          connectionParams.put(TransportConstants.PORT_PROP_NAME, &quot;port+port-offset&quot;);
          connectionParams.put(TransportConstants.HOST_PROP_NAME, &quot;192.168.1.1&quot;);
  
  
          Map&lt;String, Object&gt; connectionParams2 = new HashMap&lt;String, Object&gt;();
          connectionParams2.put(TransportConstants.PORT_PROP_NAME, &quot;port+port-offset&quot;);
          connectionParams2.put(TransportConstants.HOST_PROP_NAME, &quot;192.168.1.2&quot;);
  
  
          TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);
          TransportConfiguration transportConfiguration1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams2);
          //
  
  
  
          HornetQConnectionFactory connectionFactory = HornetQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.CF, transportConfiguration1, transportConfiguration);
  
  
          connectionFactory.setClientFailureCheckPeriod(1000);
          connectionFactory.setReconnectAttempts(3);
          connectionFactory.setConnectionTTL(1000);
  
  
  
          Connection connection = null;
          try {
              connection = connectionFactory.createConnection(&quot;username&quot;, &quot;password&quot;);
          } catch (JMSException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          if (connection != null) {
              System.out.println(&quot;JMS Connection succeed.&quot;);
  
  
          }
          // Step 9. create the JMS management queue.
          // It is a &quot;special&quot; queue and it is not looked up from JNDI but
          // constructed directly
          // see hornetq-jms.xml configuration file in server side
          Queue queue = HornetQJMSClient.createQueue(&quot;myQueue&quot;);
  
          Session session = null;
          try {
              session = connection.createSession(false, HornetQJMSConstants.PRE_ACKNOWLEDGE);
          } catch (JMSException e) {
              e.printStackTrace();
          }
  
  
          MessageProducer producer = null;
          try {
              producer = session.createProducer(queue);
          } catch (JMSException e) {
              e.printStackTrace();
          }
          
          while (true) {
              try {
                  producer.send(session.createTextMessage(&quot;asdasdas&quot;));
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
  </code></pre>
  <p>When Master/Slave Shutdown, client does not failover to another server, how to solve this problem?</p>