【转载】elastic-job链接zookeeper报错KeeperErrorCode = OperationTimeout

org.apache.zookeeper.KeeperException$OperationTimeoutException: KeeperErrorCode = OperationTimeout 报错

新同事本地启项目,springboot启动报这个错,原文如下:

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

排查过程:
网上有说防火墙的(试了不行);有说zk版本的(这边还是第三方包间接依赖的,且有包冲突,试了去掉一个没好使);

解决方案:
修改了超时时间

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

本地启动OK

原文链接

  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值