我的zookeeper是安装在本地,用的默认端口2181,版本3.4.10。dubbo版本2.5.8。
dubbo-demo-provider.xml配置文件修改为:
运行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
求解答,非常感谢!
问题已解决。把dubbo的版本降到2.5.6就可以了。
简单分析:2.5.7 在/com/alibaba/dubbo/remoting/zookeeper/zkclient包里增加了ZkClientWrapper类,用来异步获取zookeeper连接,设置了30000ms超时,但是mac上30000ms还是连不上zookeeper,所以后来调的时候就报错了
@gxh123 同样遇到。降低2.5.6是可以,但是连接很慢。
2.5.8的版本下,我通过连接手机上网,不会出现超时。
同样在win下面不会出现这个问题
@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.
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×tamp=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×tamp=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:
@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
你看看你是不是少了log4j-over-slf4j这个jar包,0.8的zkConnection需要这个jar,包不然会报错,ZkClientWrapper会把这个错误吃掉,并提示链接超时的异常,有点坑啊
I also have this problem. In my develop enviroment, I need 10s connnected zookeeper server。
can set timeout larger? @chickenlj
有终结方案没。各位大神
Most helpful comment
你看看你是不是少了log4j-over-slf4j这个jar包,0.8的zkConnection需要这个jar,包不然会报错,ZkClientWrapper会把这个错误吃掉,并提示链接超时的异常,有点坑啊