描述:
使用 zookeeper, motan 的 server 或者 client 在启动的时候有机率报 status: 500, error_code: 20004。 机器上到 Zookeeper 的 IP 是可达的。
日志:
error_message: Create registry false for url:zookeeper://IP:2181/com.weibo.api.motan.registry.RegistryService?group=default_rpc, status: 500, error_code: 20004,r=null
com.weibo.api.motan.exception.MotanFrameworkException: error_message: Create registry false for url:zookeeper://IP:2181/com.weibo.api.motan.registry.RegistryService?group=default_rpc, status: 500, error_code: 20004,r=null
at com.weibo.api.motan.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:63)
at com.weibo.api.motan.config.handler.SimpleConfigHandler.register(SimpleConfigHandler.java:111)
at com.weibo.api.motan.config.handler.SimpleConfigHandler.export(SimpleConfigHandler.java:80)
at com.weibo.api.motan.config.ServiceConfig.doExport(ServiceConfig.java:211)
at com.weibo.api.motan.config.ServiceConfig.export(ServiceConfig.java:129)
at com.weibo.api.motan.config.springsupport.ServiceConfigBean.onApplicationEvent(ServiceConfigBean.java:96)
at com.weibo.api.motan.config.springsupport.ServiceConfigBean.onApplicationEvent(ServiceConfigBean.java:48)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.ioneball.main.StartServer.main(StartServer.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 15000
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:98)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:92)
at org.I0Itec.zkclient.ZkClient.(ZkClient.java:80)
at com.weibo.api.motan.registry.zookeeper.ZookeeperRegistryFactory.createRegistry(ZookeeperRegistryFactory.java:38)
at com.weibo.api.motan.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:56)
... 21 more
配置:
regProtocol="zookeeper" name="registry" address="${zookeeperIpAndPort}" requestTimeout="15000" connectTimeout="15000" registryRetryPeriod="30000"/>