java.io.IOException: No available connection to address Address

622 views
Skip to first unread message

Manoj Khotele

unread,
Apr 11, 2016, 7:01:17 AM4/11/16
to Hazelcast
Hello,

I have created an Hazelcast cluster using EC2-auto-discovery mechanism in AWS.

But when I try to write something in a distributed map using Hazelcast client it gives exception.

I haven't came across such error in past. I don't know what's going wrong this time.
I have configured appropriate security rules to allow tcp requests on port 5701.

For brevity, I am mentioning below client code only.

================
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.ClientNetworkConfig;
import com.hazelcast.core.HazelcastInstance;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;

public class TestSimpleWriteReadOperartion {

    public static void main(String[] args) {
        Logger logger = Logger.getLogger("TestSimpleWriteReadOperartion");

        ClientNetworkConfig clientNetworkConfig = new ClientNetworkConfig();
        clientNetworkConfig.addAddress("ec2-52-29-168-91.eu-central-1.compute.amazonaws.com");
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setNetworkConfig(clientNetworkConfig);
        HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);

        try {

            logger.log(Level.INFO, "client created {0}", client);

            ConcurrentMap<Integer, String> testHzMap = client.getMap("testmap");
            int testKey = 1;
            String testValue = Integer.toString(testKey);

            testHzMap.put(testKey, testValue);
            logger.log(Level.INFO, "done with put");
            String readValue = testHzMap.get(testKey);
            logger.log(Level.INFO, "done with get");

            if (readValue.equals(testValue)) {
                logger.log(Level.INFO, "success");
            } else {
                logger.log(Level.INFO, "fail");
            }
        } finally {
            client.shutdown();
        }
    }
}

================


The logs are:
================
Apr 11, 2016 4:21:15 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is STARTING
Apr 11, 2016 4:21:15 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is STARTED
Apr 11, 2016 4:21:16 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is CLIENT_CONNECTED
Apr 11, 2016 4:21:16 PM com.hazelcast.client.spi.impl.ClientMembershipListener
INFO: 

Members [3] {
Member [172.31.18.123]:5701
Member [172.31.29.238]:5701
Member [172.31.29.239]:5701
}

Apr 11, 2016 4:21:16 PM TestSimpleWriteReadOperartion main
INFO: client created com.hazelcast.client.impl.HazelcastClientInstanceImpl@7c0c77c7
Apr 11, 2016 4:23:18 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is SHUTTING_DOWN
Apr 11, 2016 4:23:23 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is SHUTDOWN
Exception in thread "main" com.hazelcast.core.HazelcastException: java.io.IOException: No available connection to address Address[172.31.29.238]:5701
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:73)
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:63)
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:52)
at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:83)
at com.hazelcast.client.spi.ClientProxy.invokeOnPartition(ClientProxy.java:128)
at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:120)
at com.hazelcast.client.proxy.ClientMapProxy.putInternal(ClientMapProxy.java:411)
at com.hazelcast.client.proxy.ClientMapProxy.put(ClientMapProxy.java:405)
at com.hazelcast.client.proxy.ClientMapProxy.put(ClientMapProxy.java:233)
at TestSimpleWriteReadOperartion.main(TestSimpleWriteReadOperartion.java:28)
================

If it can form a client successfully, then why should it refuse connection during map put operation?

Best Regards,
Manoj

ihsan demir

unread,
Apr 12, 2016, 2:25:28 AM4/12/16
to Hazelcast
Can you check if you can reach 172.31.29.238? Client initial connection is towards one of the members, which may be a different member, it connect to others as needed to access specific partitions.

M. Sancar Koyunlu

unread,
Apr 12, 2016, 2:58:33 AM4/12/16
to Hazelcast
Hi,

Client connects to server via your first configured public address. After that client gets member list and tries to connect to all members via these addresses. Since these addresses are private network addresses, client can not reach to them. You need to configure client so that it can talk to AWS API and get public addresses. If you configure hazelcast as shown in following link, you are good to go.

Manoj Khotele

unread,
Apr 12, 2016, 11:22:08 PM4/12/16
to Hazelcast
Thanks Mr Koyunlu.
It worked.

Just a note for future readers of this post...
The documentation mentioned for programmatic configuration missed one line to call setEnabled(true) on ClientAwsConfig.

M. Sancar Koyunlu

unread,
Apr 13, 2016, 3:26:14 AM4/13/16
to Hazelcast
Thanks for the feedback on documentation. We will update it.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at https://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/0f4dbdd1-fee2-49fc-b519-eff3c377d4e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sancar Koyunlu
Software Engineer, Hazelcast
Reply all
Reply to author
Forward
0 new messages