使用ZKWrapper封装以后问题貌似解决,代码中捕捉到异常立即重连 2017-10-17 11:32:09 main-SendThread(node3:2181) Client session timed out, have not heard from server in 41057ms for sessionid 0x25f162714980a76, closing socket connection and attempting reconnect 2017-10-17 11:32:09 main-SendThread(node4:2181) Client session timed out, have not heard from server in 37810ms for sessionid 0x35f162714ad0a52, closing socket connection and attempting reconnect 2017-10-17 11:32:09 main 2017-10-17 11:32:09 main-SendThread(node4:2181) Opening socket connection to server node4/172.17.134.217:2181. Will not attempt to authenticate using SASL (unknown error) 2017-10-17 11:32:09 main-SendThread(node4:2181) Socket connection established to node4/172.17.134.217:2181, initiating session 2017-10-17 11:32:10 main-SendThread(node4:2181) Unable to reconnect to ZooKeeper service, session 0x25f162714980a76 has expired, closing socket connection 2017-10-17 11:32:10 main-EventThread Error while calling watcher java.lang.NullPointerException at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:522) at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498) 2017-10-17 11:32:10 Thread-2 exists /zillion/initend org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /zillion/initend 2017-10-17 11:32:10 main-EventThread This client just lost it's session with ZooKeeper, closing it. It will be recreated next time someone needs it org.apache.zookeeper.KeeperException$SessionExpiredException: KeeperErrorCode = Session expired at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.connectionEvent(ZooKeeperWatcher.java:702) at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.process(ZooKeeperWatcher.java:613) at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:522) at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498) 2017-10-17 11:32:10 main-EventThread Closing zookeeper sessionid=0x25f162714980a76 2017-10-17 11:32:10 main-EventThread EventThread shut down 2017-10-17 11:32:11 Thread-2 Session: 0x35f162714ad0a52 closed 2017-10-17 11:32:11 main-EventThread EventThread shut down 2017-10-17 11:32:11 Thread-2 Initiating client connection, connectString=zookeeper1:2181,zookeeper2:2181,zookeeper3:2181 sessionTimeout=300000 watcher=null 2017-10-17 11:32:11 Thread-2-SendThread(node3:2181) Opening socket connection to server node3/172.17.134.218:2181. Will not attempt to authenticate using SASL (unknown error) 2017-10-17 11:32:11 Thread-2-SendThread(node3:2181) Socket connection established to node3/172.17.134.218:2181, initiating session 2017-10-17 11:32:11 Thread-2-SendThread(node3:2181) Session establishment complete on server node3/172.17.134.218:2181, sessionid = 0x25f162714980d8d, negotiated timeout = 40000 2017-10-17 11:32:11 Thread-2-EventThread Error while calling watcher java.lang.NullPointerException at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:522) at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:498)