我的WEB專案中使用curator作為Zookeeper的客戶端,設定重連策略如下:
@Autowired
public ZookeeperUtil(EnvironmentUtil environmentUtil){
this.environmentUtil = environmentUtil;
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000,3);
zookeeperClient = CuratorFrameworkFactory.newClient("127.0.0.1:2181",retryPolicy);
zookeeperClient.start();
}
當127.0.0.1:2181這臺機器的Zookeeper服務不啟動時,zookeeperClient.start()后就會無限重連,重連策略沒有生效,請問是什么原因呢?
例外如下,不止這一個,只要zookeeper服務不啟動,就會一直不停的重連下去:
2019-12-03 14:23:03.085 INFO 4387 --- [restartedMain-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2019-12-03 14:23:03.086 WARN 4387 --- [restartedMain-SendThread(localhost:2181)] org.apache.zookeeper.ClientCnxn : Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
uj5u.com熱心網友回復:
遇到了同樣的問題,不知道博主解決沒有!轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/165232.html
標籤:Web 開發
上一篇:uni-app 呼叫 jar 包
下一篇:TCP通信軟體開發--Qt
