javaandroidapache-zookeeperapache-curator

android use zk client with curator to connect zk get data failed with connectionLoss


zk client: android use curator 4.2

zk server: zk version 3.5.6

problem: when i connect zk to get data from "/" failed with

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /

                class MyThread implements Runnable {
                    @Override
                    public void run() {
                        try {
                            String ip = "192.168.0.111";
                            System.out.println("start new");
                            ExponentialBackoffRetry retry = new ExponentialBackoffRetry(10000, 3);
                            System.out.println("end new");
                            CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(ip, retry );
                            System.out.println("end new2");

                            curatorFramework.start();

                            Stat nodeStat = new Stat();
                            byte[] nodeInfo = curatorFramework.getData()
                                    .storingStatIn(nodeStat)
                                    .forPath("/");
                            System.out.println("===node info is:" + new String(nodeInfo));

                            curatorFramework.create().creatingParentContainersIfNeeded()
                                    .withMode(CreateMode.PERSISTENT)
                                    .withACL(ZooDefs.Ids.OPEN_ACL_UNSAFE)
                                    .forPath("/nodeTest", "testData".getBytes());
                            System.out.println("wtf");
                            button1.setText("nihaoya");
                        } catch (Exception e) {
                            System.out.println( e.toString());
                        }
                    }
                }

Solution

  • i fixed it, just close use System.setProperties(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, "false");