zookeeper连接报某个节点connection loss

测试环境有一套zookeeper,使用各种客户端总是会报connection loss的问题,但是直接在机器上进行连接是就没问题。之前没当回事,以为是客户端的bug。现在使用zkui进行管理时,报/dubbo节点 connection loss的问题,没报其他节点的问题。zkui 是java客户端,可以直接使用源码进行调试,我就在报异常的地方加了try catch,在异常时进行跳过,然后zkui可以正常展示加载数据了。

因为是 /dubbo节点除的问题,所以我直接在机器上连接zk,然后对/dubbo节点进行读取get和列表ls操作,然后报出如下错误。

[zk: 127.0.0.1:2181(CONNECTED) 0] ls /dubbo
2022-08-02 12:10:19,859 [myid:] - WARN  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1164] - Session 0x100000333730010 for server localhost/127.0.0.1:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Packet len4724847 is out of range!
	at org.apache.zookeeper.ClientCnxnSocket.readLength(ClientCnxnSocket.java:113)
	at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:79)
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:366)
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
Exception in thread "main" org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /dubbo
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:102)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
	at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1541)
	at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1569)
	at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:732)
	at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:600)
	at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:372)
	at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:332)
	at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:291)

WATCHER::

WatchedEvent state:Disconnected type:None path:null

然后搜索 Packet len* is out of range! 问题相关的文档,大体逻辑就是,创建与zookeeper连接之后,要对某个节点进行读写操作,为了提高吞吐量,先判断下该节点数据量大小是否超过设置的jute.maxbuffer,如果是,就抛出异常。文档https://blog.csdn.net/liuxinghao/article/details/59071373。文档中给出了解决方法:在创建zookeeper前,手动设置jute.maxbuffer的值。

System.setProperty("jute.maxbuffer", 4096 * 1024 * 10 + "");
ZooKeeper zk = ServletUtil.INSTANCE.getZookeeper(request, response, zkServerLst[0], globalProps);

然后zkui的功能就正常使用了,问题解决。

参考文档:https://blog.csdn.net/liuxinghao/article/details/59071373

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值