我的zookeeper是安装在本地,用的默认端口2181,版本3.4.10。dubbo版本2.5.8。
dubbo-demo-provider.xml配置文件修改为:
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
运行Provider就会报下面的错:
[24/12/17 04:56:57:057 CST] main ERROR zkclient.ZkClientWrapper: [DUBBO] Timeout! zookeeper server can not be connected in : 30000ms!, dubbo version: 2.0.0, current host: 127.0.0.1
最后导致
Caused by: java.lang.IllegalStateException: Zookeeper is not connected yet!
at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkClientWrapper.createPersistent(ZkClientWrapper.java:82)
at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.createPersistent(ZkclientZookeeperClient.java:45)
at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:47)
at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41)
at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:110)
... 21 more
求解答,非常感谢!
解决办法:
1,检查jdk版本,jdk1.6 dubbo 2.5版本,2.6版本则使用jdk1.8,dubbo的版本过高或者过低的原因!
2,配置zookeeper中的配置文件,配置超时时间,配大一点!