Tag Archives: organization Apache. Zoo keeper. Keeperexception $operationtimeoutexception: keepererrorcode = operation timeout

[Solved] org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout

New colleagues locally start the project, springboot start reported this error, the original is as follows:

2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:java.io.tmpdir=C:\Users\ADMINI~1\AppData\Local\Temp\
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:java.compiler=<NA>
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:os.name=Windows 10
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:os.arch=amd64
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:os.version=10.0
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:user.name=Administrator
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:user.home=C:\Users\Administrator
2021-12-10.14:35:02.202 restartedMain INFO ZooKeeper : Client environment:user.dir=D:\WorkSpace\league-api
2021-12-10.14:35:02.203 restartedMain INFO ZooKeeper : Initiating client connection, connectString=test-zk01-a.zk.xxx.com:2181 sessionTimeout=600000 watcher=org.apache.curator.ConnectionState@43224f71
2021-12-10.14:35:12.584 Curator-Framework-0 INFO CuratorFrameworkImpl : backgroundOperationsLoop exiting
2021-12-10.14:35:13.651 restartedMain-SendThread(10.20.0.12:2181) INFO ClientCnxn : Opening socket connection to server 10.20.0.12/10.20.0.12:2181. Will not attempt to authenticate using SASL (unknown error)
2021-12-10.14:35:13.677 restartedMain-SendThread(10.20.0.12:2181) INFO ClientCnxn : Socket connection established to 10.20.0.12/10.20.0.12:2181, initiating session
2021-12-10.14:35:14.131 restartedMain-SendThread(10.20.0.12:2181) INFO ClientCnxn : Session establishment complete on server 10.20.0.12/10.20.0.12:2181, sessionid = 0x17af8b923322751, negotiated timeout = 40000
2021-12-10.14:35:14.185 restartedMain INFO ZooKeeper : Session: 0x17af8b923322751 closed
2021-12-10.14:35:14.185 restartedMain-EventThread INFO ClientCnxn : EventThread shut down for session: 0x17af8b923322751
2021-12-10.14:35:14.206 restartedMain WARN AnnotationConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticJobAutoConfiguration': Invocation of init method failed; nested exception is com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
2021-12-10.14:35:14.208 restartedMain INFO StandardService : Stopping service [Tomcat]
2021-12-10.14:35:14.287 restartedMain INFO ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-10.14:35:14.491 restartedMain ERROR SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticJobAutoConfiguration': Invocation of init method failed; nested exception is com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
at com.yueche.league.LeagueApiApplication.main(LeagueApiApplication.java:8)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: com.dangdang.ddframe.job.reg.exception.RegException: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
at com.dangdang.ddframe.job.reg.exception.RegExceptionHandler.handleException(RegExceptionHandler.java:52)
at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.init(ZookeeperRegistryCenter.java:107)
at com.yueche.league.common.job.ElasticJobAutoConfiguration.initElasticJob(ElasticJobAutoConfiguration.java:40)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157)
... 23 common frames omitted
Caused by: org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout
at com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.init(ZookeeperRegistryCenter.java:102)
... 31 common frames omitted

Process finished with exit code 0

The troubleshooting process.
The Internet has said firewall (tried not to); some say zk version (this side or third-party package indirectly dependent, and there are package conflicts, tried to remove a did not work);

Solution:
Modified the timeout time

ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(serverList, namespace);
zookeeperConfiguration.setSessionTimeoutMilliseconds(600000);
zookeeperConfiguration.setConnectionTimeoutMilliseconds(600000);
zookeeperConfiguration.setMaxSleepTimeMilliseconds(30000);
zookeeperConfiguration.setBaseSleepTimeMilliseconds(10000);
ZookeeperRegistryCenter regCenter = new ZookeeperRegistryCenter(zookeeperConfiguration);

Local boot OK