Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start two HZ clients from the same JVM #9008

Closed
dsukhoroslov opened this issue Sep 28, 2016 · 1 comment
Closed

Unable to start two HZ clients from the same JVM #9008

dsukhoroslov opened this issue Sep 28, 2016 · 1 comment
Labels
Source: Community PR or issue was opened by a community user

Comments

@dsukhoroslov
Copy link
Contributor

HZ 3.7.1. I need to connect two separate HZ clients from a single Java app to the same HZ server (cluster). The first client connect successfully, but the second one cannot connect and fails with error:

Exception in thread "Thread-1" java.lang.IllegalStateException: Unable to connect to any address in the config! The following addresses were tried:[localhost/127.0.0.1:10000]
    at com.hazelcast.client.spi.impl.ClusterListenerSupport.connectToCluster(ClusterListenerSupport.java:175)
    at com.hazelcast.client.spi.impl.ClientClusterServiceImpl.start(ClientClusterServiceImpl.java:191)
    at com.hazelcast.client.impl.HazelcastClientInstanceImpl.start(HazelcastClientInstanceImpl.java:379)
    at com.hazelcast.client.HazelcastClientManager.newHazelcastClient(HazelcastClientManager.java:78)
    at com.hazelcast.client.HazelcastClient.newHazelcastClient(HazelcastClient.java:72)
    at com.bagri.xdm.cache.hazelcast.HzClientTest$ClientTest.run(HzClientTest.java:48)
    at java.lang.Thread.run(Thread.java:745)

The very simple reproducer test is:

public class HzClientTest {

    @Test
    public void TwoClientsTest() throws Exception {
        Config config = new Config();
        config.getNetworkConfig().setPortAutoIncrement(true);
        config.getGroupConfig().setName("schema");
        config.getGroupConfig().setPassword("password");
        JoinConfig join = config.getNetworkConfig().getJoin();
        join.getMulticastConfig().setEnabled(false);
        join.getTcpIpConfig().addMember("localhost:10000").setEnabled(true);
        config.setProperty("hazelcast.logging.type", "slf4j");
        HazelcastInstance server = Hazelcast.newHazelcastInstance(config);

        new Thread(new ClientTest()).start();
        Thread.sleep(1000);
        //assertEquals(1, server.getClientService().getConnectedClients().size());

        new Thread(new ClientTest()).start();
        Thread.sleep(1000);
        //assertEquals(2, server.getClientService().getConnectedClients().size());

        Thread.sleep(5000);
    }

    private class ClientTest implements Runnable {

        @Override
        public void run() {
            ClientConfig config = new ClientConfig();
            config.getGroupConfig().setName("schema");
            config.getGroupConfig().setPassword("password");
            config.getNetworkConfig().addAddress("localhost:10000");
            HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
        }
    }
}

Please have a look. This functionality used to work in 3.6.x versions.

Thanks, Denis.

@dsukhoroslov
Copy link
Contributor Author

Please wait :). The test I provided is a bit wrong, after I fix it it does work properly. But not my app..

@mmedenjak mmedenjak added the Source: Community PR or issue was opened by a community user label Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Community PR or issue was opened by a community user
Projects
None yet
Development

No branches or pull requests

2 participants