The @autowired
Public ZookeeperUtil (EnvironmentUtil EnvironmentUtil) {
Enclosing environmentUtil=environmentUtil;
RetryPolicy RetryPolicy=new ExponentialBackoffRetry (1000, 3);
ZookeeperClient=CuratorFrameworkFactory. NewClient (127.0.0.1: "2181", retryPolicy);
ZookeeperClient. Start ();
}
When 127.0.0.1:2181 the Zookeeper service of the machine is not started, zookeeperClient. After the start () will be infinite reconnection, reconnection strategy without effect, what reason be excuse me?
Abnormal as follows, this was not the only, as long as the zookeeper service does not start, will be kept reconnection:
The 2019-12-03 14:23:03. 4387-085 the INFO [restartedMain - SendThread (localhost: 2181)] org. Apache. Zookeeper. ClientCnxn: Opening a socket connection to the server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
The 2019-12-03 14:23:03. 4387-086 WARN [restartedMain - SendThread (localhost: 2181)] org. Apache. Zookeeper. ClientCnxn: Session 0 x0 for server null, unexpected error, closing the socket connection and attempting the reconnect
Java.net.ConnectException: Connection refused
At sun. Nio. Ch. SocketChannelImpl. CheckConnect (Native Method)
At sun. Nio. Ch. SocketChannelImpl. FinishConnect (SocketChannelImpl. Java: 717)
The at org. Apache. Zookeeper. ClientCnxnSocketNIO. DoTransport (ClientCnxnSocketNIO. Java: 350)
The at org. Apache. The zookeeper. ClientCnxn $SendThread. Run (ClientCnxn. Java: 1068)
CodePudding user response:
Meet the same problem, don't know the blogger solve have no!