title: hazelcast client exception when connecting to server
body: <p>I am trying to use hazelcast v3.2.4 (same version on server and client).  The server (as simple an implementation that I could put in place) is running on a server.  The client tries to connect to the remote server - the server prints the authentication requests but I receive the following log outputs (including exceptions) - any ideas on what I can do differently (copying both log output and config file).  I am trying to connect via TCP/IP and I checked for network connectivity - I could not see anything blocking the connection.  </p>
  
  <p><strong>Line of Code mentioned in stack:</strong></p>
  
  <pre><code>final ClientConfig config= new XmlClientConfigBuilder("config/hazelcast.xml").build();
  HazelcastInstance hcast = HazelcastClient.newHazelcastClient(config);   //this is mentioned in stack trace
  </code></pre>
  
  <p><strong>Config</strong></p>
  
  <pre><code>&lt;hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-client-config-3.1.xsd"
             xmlns="http://www.hazelcast.com/schema/config"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;group&gt;
          &lt;name&gt;dev&lt;/name&gt; 
          &lt;password&gt;dev-pass&lt;/password&gt; 
      &lt;/group&gt;
      &lt;management-center enabled="false"&gt;http://localhost:8080/mancenter&lt;/management-center&gt;
      &lt;network&gt;
         &lt;cluster-members&gt;
              &lt;address&gt;xxx.xxx.xxx.xxx&lt;/address&gt;
          &lt;/cluster-members&gt;
          &lt;smart-routing&gt;true&lt;/smart-routing&gt;
          &lt;redo-operation&gt;true&lt;/redo-operation&gt;
          &lt;connection-pool-size&gt;30&lt;/connection-pool-size&gt;
  
          &lt;port auto-increment="true" port-count="100"&gt;5701&lt;/port&gt;
          &lt;outbound-ports&gt;
              &lt;ports&gt;0&lt;/ports&gt;
          &lt;/outbound-ports&gt;
          &lt;join&gt;
              &lt;multicast enabled="false"&gt;
                  &lt;multicast-group&gt;224.2.2.3&lt;/multicast-group&gt;
                  &lt;multicast-port&gt;54327&lt;/multicast-port&gt;
              &lt;/multicast&gt;
              &lt;tcp-ip enabled="false"&gt;
                  &lt;interface&gt;xxx.xxx.xxx.xxx&lt;/interface&gt;
              &lt;/tcp-ip&gt;
              &lt;aws enabled="false"&gt;
                  &lt;access-key&gt;my-access-key&lt;/access-key&gt;
                  &lt;secret-key&gt;my-secret-key&lt;/secret-key&gt;
                  &lt;region&gt;us-west-1&lt;/region&gt;
                  &lt;host-header&gt;ec2.amazonaws.com&lt;/host-header&gt;
                  &lt;security-group-name&gt;hazelcast-sg&lt;/security-group-name&gt;
                  &lt;tag-key&gt;type&lt;/tag-key&gt;
                  &lt;tag-value&gt;hz-nodes&lt;/tag-value&gt;
              &lt;/aws&gt;
          &lt;/join&gt;
          &lt;interfaces enabled="false"&gt;
              &lt;interface&gt;10.10.1.*&lt;/interface&gt;
          &lt;/interfaces&gt;
          &lt;ssl enabled="false" /&gt;
          &lt;socket-interceptor enabled="false" /&gt;
          &lt;symmetric-encryption enabled="false"&gt;
              &lt;algorithm&gt;PBEWithMD5AndDES&lt;/algorithm&gt;
              &lt;salt&gt;thesalt&lt;/salt&gt;
              &lt;password&gt;thepass&lt;/password&gt;
              &lt;iteration-count&gt;19&lt;/iteration-count&gt;
          &lt;/symmetric-encryption&gt;
      &lt;/network&gt;
  </code></pre>
  
  <p><strong>Log output</strong></p>
  
  <pre><code>Sep 05, 2014 4:06:02 PM com.hazelcast.core.LifecycleService
  INFO: HazelcastClient[hz.client_0_dev][3.2.4] is STARTING
  Sep 05, 2014 4:06:02 PM com.hazelcast.core.LifecycleService
  INFO: HazelcastClient[hz.client_0_dev][3.2.4] is STARTED
  Sep 05, 2014 4:06:02 PM com.hazelcast.core.LifecycleService
  INFO: HazelcastClient[hz.client_0_dev][3.2.4] is CLIENT_CONNECTED
  Sep 05, 2014 4:06:02 PM com.hazelcast.client.spi.ClientClusterService
  INFO: 
  
  Members [1] {
      Member [127.0.0.1]:5701
  }
  
  Sep 05, 2014 4:06:22 PM com.hazelcast.client.spi.ClientPartitionService
  SEVERE: Error while fetching cluster partition table!
  com.hazelcast.spi.exception.RetryableIOException: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:319)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.tryToConnect(ClientConnectionManagerImpl.java:261)
      at com.hazelcast.client.spi.impl.ClientInvocationServiceImpl.send(ClientInvocationServiceImpl.java:149)
      at com.hazelcast.client.spi.impl.ClientInvocationServiceImpl.invokeOnTarget(ClientInvocationServiceImpl.java:59)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getPartitionsFrom(ClientPartitionServiceImpl.java:105)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getInitialPartitions(ClientPartitionServiceImpl.java:94)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.start(ClientPartitionServiceImpl.java:60)
      at com.hazelcast.client.HazelcastClient.start(HazelcastClient.java:223)
      at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:186)
      at com.xxx.test.HCastClientAccessor.getHCastInstance(HCastClientAccessor.java:55)
      at com.xxx.test.HCastTest.&lt;clinit&gt;(HCastTest.java:12)
  Caused by: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
      at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:262)
      at java.util.concurrent.FutureTask.get(FutureTask.java:119)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:316)
      ... 10 more
  Caused by: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
      at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:45)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:384)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:332)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:57)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
      at java.util.concurrent.FutureTask.run(FutureTask.java:166)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:724)
      at com.hazelcast.util.executor.PoolExecutorThreadFactory$ManagedThread.run(PoolExecutorThreadFactory.java:59)
  Caused by: java.net.ConnectException: Connection refused: no further information
      at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
      at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:708)
      at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:115)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:365)
      ... 11 more
  </code></pre>
  
  <p><strong>Server output</strong></p>
  
  <pre><code>INFO: [127.0.0.1]:5701 [dev] [3.2.4] Accepting socket connection from /xxx.xxx.xxx.xxx:49705
  Sep 05, 2014 4:05:57 PM com.hazelcast.nio.TcpIpConnectionManager
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] 5701 accepted socket connection from /xxx.xxx.xxx.xxx:49705
  Sep 05, 2014 4:05:57 PM com.hazelcast.client.AuthenticationRequest
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] Received auth from Connection [/xxx.xxx.xxx.xxx:49705 -&gt; null] live=true, client=true, type=JAVA_CLIENT, successfully authenticated
  Sep 05, 2014 4:09:43 PM com.hazelcast.nio.TcpIpConnection
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] Connection [Address[xxx.xxx.xxx.xxx]:49705] lost. Reason: java.io.IOException[Connection reset by peer]
  Sep 05, 2014 4:09:43 PM com.hazelcast.client.ClientEngine
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] Destroying ClientEndpoint{conn=Connection [/xxx.xxx.xxx.xxx:49705 -&gt; Address[xxx.xxx.xxx.xxx]:49705] live=false, client=true, type=JAVA_CLIENT, uuid='70afcf60-96e0-444d-8981-3aa983530514', firstConnection=true, authenticated=true}
  Sep 05, 2014 4:09:43 PM com.hazelcast.nio.ReadHandler
  WARNING: [127.0.0.1]:5701 [dev] [3.2.4] hz._hzInstance_1_dev.IO.thread-in-0 Closing socket to endpoint Address[192.168.101.106]:49705, Cause:java.io.IOException: Connection reset by peer
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I switched to this client config but I still get an exception on the client end.  I copied the server and client output - the server receives the connection request but then on the client end, I see the same error as mentioned above <strong>"SEVERE: Error while fetching cluster partition table!"</strong> - same trace as above. </p>
  
  <p><strong>New client config</strong></p>
  
  <pre><code>&lt;hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-client-config-3.2.4.xsd"
             xmlns="http://www.hazelcast.com/schema/config"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
      &lt;group&gt;
          &lt;name&gt;dev&lt;/name&gt; 
          &lt;password&gt;dev-pass&lt;/password&gt; 
      &lt;/group&gt;
      &lt;management-center enabled="false"&gt;http://localhost:8080/mancenter&lt;/management-center&gt;
      &lt;network&gt;
         &lt;cluster-members&gt;
              &lt;address&gt;xxx.xxx.xxx.xxx&lt;/address&gt;
          &lt;/cluster-members&gt;
          &lt;smart-routing&gt;true&lt;/smart-routing&gt;
          &lt;redo-operation&gt;true&lt;/redo-operation&gt;
          &lt;connection-timeout&gt;60000&lt;/connection-timeout&gt;
          &lt;connection-attempt-limit&gt;10&lt;/connection-attempt-limit&gt;
          &lt;connection-pool-size&gt;30&lt;/connection-pool-size&gt;
      &lt;/network&gt;
          &lt;executor-pool-size&gt;40&lt;/executor-pool-size&gt; &lt;!-- added --&gt;
  
  &lt;/hazelcast-client&gt;
  </code></pre>
  
  <p><strong>Server output:</strong></p>
  
  <pre><code>Sep 07, 2014 5:57:01 PM com.hazelcast.nio.SocketAcceptor
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] Accepting socket connection from /xxx.xxx.xxx.xxx:58521
  Sep 07, 2014 5:57:01 PM com.hazelcast.nio.TcpIpConnectionManager
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] 5701 accepted socket connection from /xxx.xxx.xxx.xxx:58521
  Sep 07, 2014 5:57:03 PM com.hazelcast.client.AuthenticationRequest
  INFO: [127.0.0.1]:5701 [dev] [3.2.4] Received auth from Connection [/xxx.xxx.xxx.xxx:58521 -&gt; null] live=true, client=true, type=JAVA_CLIENT, successfully authenticated
  </code></pre>
  
  <p><strong>Client output</strong></p>
  
  <pre><code>Sep 07, 2014 5:58:04 PM com.hazelcast.client.spi.ClientPartitionService
  SEVERE: Error while fetching cluster partition table!
  com.hazelcast.spi.exception.RetryableIOException: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.getOrConnect(ClientConnectionManagerImpl.java:319)
      at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.tryToConnect(ClientConnectionManagerImpl.java:261)
      at com.hazelcast.client.spi.impl.ClientInvocationServiceImpl.send(ClientInvocationServiceImpl.java:149)
      at com.hazelcast.client.spi.impl.ClientInvocationServiceImpl.invokeOnTarget(ClientInvocationServiceImpl.java:59)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getPartitionsFrom(ClientPartitionServiceImpl.java:105)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.getInitialPartitions(ClientPartitionServiceImpl.java:94)
      at com.hazelcast.client.spi.impl.ClientPartitionServiceImpl.start(ClientPartitionServiceImpl.java:60)
      at com.hazelcast.client.HazelcastClient.start(HazelcastClient.java:223)
      at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:186)
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I tried this for client and server and I got the same exception as above - what am I doing wrong:</p>
  
  <p><strong>Client</strong>
          ClientConfig clientConfig = new ClientConfig().addAddress("xxx.xxx.xxx.xxx");
            HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);</p>
  
  <p><strong>Server</strong></p>
  
  <pre><code>HazelcastInstance hcast = Hazelcast.newHazelcastInstance();
  </code></pre>
  
  <p><strong>Update</strong>
  In short, make sure the config for both server and client are correct (do not mix up tags from one set to another).  For the server, ensure that the hazelcast server is listening on the external IP address (not the loopback addresS), that there are no firewall settings blocking the connection (on client, server or in-between).  Thanks to Peter - I'm back to using hazelcast and enjoying my experience of using this tool.  Strongly recommended!</p>