dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

I got the error `Zookeeper is not connected yet!` when run official demo on my mac OS.

Open gxh123 opened this issue 8 years ago • 9 comments

我的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 求解答,非常感谢!

gxh123 avatar Dec 24 '17 09:12 gxh123

问题已解决。把dubbo的版本降到2.5.6就可以了。 简单分析:2.5.7 在/com/alibaba/dubbo/remoting/zookeeper/zkclient包里增加了ZkClientWrapper类,用来异步获取zookeeper连接,设置了30000ms超时,但是mac上30000ms还是连不上zookeeper,所以后来调的时候就报错了

gxh123 avatar Dec 24 '17 12:12 gxh123

@gxh123 同样遇到。降低2.5.6是可以,但是连接很慢。 2.5.8的版本下,我通过连接手机上网,不会出现超时。 同样在win下面不会出现这个问题

cuiken avatar Dec 25 '17 06:12 cuiken

@gxh123 @cuiken Why you can't successfully connect to the ZK server in 30000? Isn't this a potential problem? And besides, ZkclientWrapper will keep monitoring the connection effort to ZK server, and take care of the connection when it's finally connected.

This is only a problem of your developing environment, so we don't recommend degrade to 2.5.6.

chickenlj avatar Dec 28 '17 03:12 chickenlj

when I run dubbo service by docker ,i always got this problem

2018-01-03T09:41:44.464972049Z com.alibaba.dubbo.rpc.RpcException: Failed to subscribe consumer://10.0.0.10/com.xxxxxx.ecshop.product.api.IOfferGoodsService?application=gpf-consumer-app&category=providers,configurators,routers&default.check=false&default.group=test&default.timeout=30000&default.version=1.0&dubbo=2.5.8&interface=com.xxxxxx.ecshop.product.api.IOfferGoodsService&methods=queryReport,getShopSeachTerm,getShopProductList,getShopInformation,removeWords,querySeller,queryAssess,getProductNameAuto,getWords,queryDateBySortType&pid=1&revision=1.0.0-Release&side=consumer&timestamp=1514971820460&version=1.0 to zookeeper zookeeper://zookeeper:2181/com.alibaba.dubbo.registry.RegistryService?application=gpf-consumer-app&dubbo=2.5.8&interface=com.alibaba.dubbo.registry.RegistryService&pid=1&timestamp=1514971782861, cause: Zookeeper is not connected yet! 2018-01-03T09:41:44.464984986Z at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:185) 2018-01-03T09:41:44.464991331Z at com.alibaba.dubbo.registry.support.FailbackRegistry.retry(FailbackRegistry.java:377) 2018-01-03T09:41:44.464997478Z at com.alibaba.dubbo.registry.support.FailbackRegistry$1.run(FailbackRegistry.java:70) 2018-01-03T09:41:44.465003521Z at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 2018-01-03T09:41:44.465009467Z at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) 2018-01-03T09:41:44.465015351Z at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) 2018-01-03T09:41:44.465021526Z at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) 2018-01-03T09:41:44.465027753Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 2018-01-03T09:41:44.465033693Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 2018-01-03T09:41:44.465039739Z at java.lang.Thread.run(Thread.java:748) 2018-01-03T09:41:44.465045596Z Caused by: java.lang.IllegalStateException: Zookeeper is not connected yet! 2018-01-03T09:41:44.465051446Z at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkClientWrapper.createPersistent(ZkClientWrapper.java:82) 2018-01-03T09:41:44.465057548Z at com.alibaba.dubbo.remoting.zookeeper.zkclient.ZkclientZookeeperClient.createPersistent(ZkclientZookeeperClient.java:45) 2018-01-03T09:41:44.465063837Z at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:47) 2018-01-03T09:41:44.465075070Z at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41) 2018-01-03T09:41:44.465081931Z at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:41) 2018-01-03T09:41:44.465088218Z at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:176) 2018-01-03T09:41:44.465094405Z ... 9 more

version: '3' services: zookeeper: image: 'registry.aliyuncs.com/acs-sample/zookeeper:3.4.8' deploy: replicas: 1 restart_policy: condition: on-failure hostname: zookeeper networks: - gpfnetwork xxxxxx-order-service: image: registry.cn-shanghai.aliyuncs.com/xxxxxx/xxxxxx-order-service:latest depends_on: - zookeeper deploy: replicas: 2 restart_policy: condition: on-failure networks: - gpfnetwork xxxxxx-user-service: image: registry.cn-shanghai.aliyuncs.com/xxxxxx/xxxxxx-user-service:latest depends_on: - zookeeper deploy: replicas: 2 restart_policy: condition: on-failure networks: - gpfnetwork xxxxxx-product-service: image: registry.cn-shanghai.aliyuncs.com/xxxxxx/xxxxxx-product-service:latest depends_on: - zookeeper networks: - gpfnetwork deploy: replicas: 2 restart_policy: condition: on-failure xxxxxx-webapp-center: image: registry.cn-shanghai.aliyuncs.com/xxxxxx/xxxxxx-webapp-center:latest depends_on: - zookeeper networks: - gpfnetwork deploy: replicas: 2 restart_policy: condition: on-failure ports: - "8080:8080" xxxxxx-webapp-app: image: registry.cn-shanghai.aliyuncs.com/xxxxxx/xxxxxx-webapp-app:latest depends_on: - zookeeper deploy: replicas: 2 restart_policy: condition: on-failure networks: - gpfnetwork ports: - "8060:8080" networks: gpfnetwork:

zhangruhong avatar Jan 03 '18 10:01 zhangruhong

@gxh123 @chickenlj
it can be fix by add 127.0.0.1 your_host_name.local ::1 your_host_name.local

in your hosts file

http://blog.csdn.net/puma_dong/article/details/53096149

cuiken avatar Jan 08 '18 05:01 cuiken

你看看你是不是少了log4j-over-slf4j这个jar包,0.8的zkConnection需要这个jar,包不然会报错,ZkClientWrapper会把这个错误吃掉,并提示链接超时的异常,有点坑啊

lazyman54 avatar May 01 '18 10:05 lazyman54

I also have this problem. In my develop enviroment, I need 10s connnected zookeeper server。

GLBB avatar Oct 01 '19 14:10 GLBB

can set timeout larger? @chickenlj

GLBB avatar Oct 01 '19 14:10 GLBB

有终结方案没。各位大神

powerLeePlus avatar Nov 27 '20 10:11 powerLeePlus