错误信息如下:

org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /eclipse
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783)
	at com.shm.bigdata.zk.SimpleZkClient.testCreate(SimpleZkClient.java:31)

原因:连接还没有创建完成,就操作节点就会报异常?

解决办法:连接超时时间要设置的足够大
private static final int sessionTimeout = 30000;
在这里插入图片描述

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐