Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法获取服务 #120

Closed
gongrico opened this issue Jun 18, 2016 · 11 comments
Closed

无法获取服务 #120

gongrico opened this issue Jun 18, 2016 · 11 comments

Comments

@gongrico
Copy link

com.weibo.api.motan.exception.MotanFrameworkException: error_message: Failed to subscribe motan://169.254.130.54:0/com.xxxxxxx.passport.service.AccountService?group=default_rpc to zookeeper(zookeeper://127.0.0.1:2181/com.weibo.api.motan.registry.RegistryService?group=default_rpc), cause: null, status: 503, error_code: 20001,r=

一直报这个错误,按照官方demo跑不起来,

服务端配置

<motan:registry regProtocol="zookeeper" name="registry"
address="127.0.0.1:2181" connectTimeout="2000" />

<motan:protocol id="demoMotan" default="true" name="motan"
    maxServerConnection="80000" maxContentLength="1048576"
    maxWorkerThread="800" minWorkerThread="20" />

<motan:basicService id="serviceBasicConfig"
    accessLog="false" shareChannel="true" application="myMotanDemo"
    registry="registry" />

<bean id="accountService" class="com.xxxxxx.passport.service.imple.AccountServiceImple"></bean>
<motan:service interface="com.xxxxxxx.passport.service.AccountService"
    ref="accountService" export="demoMotan:8002" basicService="serviceBasicConfig" />`

客户端配置

<motan:registry regProtocol="zookeeper" name="nas_registry"
address="127.0.0.1:2181" connectTimeout="2000" />

<motan:protocol name="motan" default="true" haStrategy="failover"
    loadbalance="roundrobin" maxClientConnection="10" minClientConnection="2" />

<motan:basicReferer id="motantestClientBasicConfig"
    requestTimeout="200" accessLog="false" retries="2" application="myMotanDemo"
    protocol="motan" registry="nas_registry" throwException="false" check="true" />

<motan:referer id="accountService"
    interface="com.xxxxxxx.passport.service.AccountService"
    connectTimeout="300" requestTimeout="300" basicReferer="motantestClientBasicConfig" />`
@sunnights
Copy link
Collaborator

sunnights commented Jun 19, 2016

client和server的registry配置有吗,我看你client配的registry="nas_registry

@gongrico
Copy link
Author

gongrico commented Jun 19, 2016

zookeeper配置

<motan:registry regProtocol="zookeeper" name="nas_registry"
        address="127.0.0.1:2181" connectTimeout="2000" />

zookeeper信息

2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:java.io.tmpdir=C:\Users\rico\AppData\Local\Temp\
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:java.compiler=<NA>
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:os.name=Windows 7
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:os.arch=amd64
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:os.version=6.1
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:user.name=rico
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:user.home=C:\Users\rico
2016-06-19 11:26:39,080 [myid:] - INFO  [main:Environment@100] - Server environment:user.dir=C:\Users\rico\Documents\NetSarang\Xshell\Sessions
2016-06-19 11:26:39,096 [myid:] - INFO  [main:ZooKeeperServer@787] - tickTime set to 2000
2016-06-19 11:26:39,096 [myid:] - INFO  [main:ZooKeeperServer@796] - minSessionTimeout set to -1
2016-06-19 11:26:39,096 [myid:] - INFO  [main:ZooKeeperServer@805] - maxSessionTimeout set to -1
2016-06-19 11:26:39,158 [myid:] - INFO  [main:NIOServerCnxnFactory@89] - binding to port 0.0.0.0/0.0.0.0:2181
2016-06-19 11:27:20,001 [myid:] - INFO  [SessionTracker:ZooKeeperServer@355] - Expiring session 0x15564d11724000f, timeout of 40000ms exceeded
2016-06-19 11:27:20,002 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@489] - Processed session termination for sessionid: 0x15564d11724000f
2016-06-19 11:27:20,002 [myid:] - INFO  [SyncThread:0:FileTxnLog@199] - Creating new log file: log.bb04
2016-06-19 11:27:30,176 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:49381
2016-06-19 11:27:30,181 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@900] - Client attempting to establish new session at /127.0.0.1:49381
2016-06-19 11:27:30,190 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@645] - Established session 0x15566b227300000 with negotiated timeout 40000 for client /127.0.0.1:49381
2016-06-19 11:27:33,549 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /127.0.0.1:49394
2016-06-19 11:27:33,552 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@900] - Client attempting to establish new session at /127.0.0.1:49394
2016-06-19 11:27:33,553 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@645] - Established session 0x15566b227300001 with negotiated timeout 40000 for client /127.0.0.1:49394

@sunnights
Copy link
Collaborator

建议debug进motan-zookeeper-registry包下,ZookeeperRegistry类里有个subscribeService方法,确认一下错误的具体位置和信息

@gongrico
Copy link
Author

  com.weibo.api.motan.exception.MotanFrameworkException: error_message: Failed to subscribe motan://169.254.130.54:0/com.xxxxxx.passport.service.AccountService?group=default_rpc to zookeeper(zookeeper://127.0.0.1:2181/com.weibo.api.motan.registry.RegistryService?group=default_rpc), cause: null, status: 503, error_code: 20001,r=
    at com.weibo.api.motan.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:98)
    at com.weibo.api.motan.registry.support.AbstractRegistry.subscribe(AbstractRegistry.java:101)
    at com.weibo.api.motan.registry.support.FailbackRegistry.subscribe(FailbackRegistry.java:107)
    at com.weibo.api.motan.cluster.support.ClusterSupport.init(ClusterSupport.java:90)
    at com.weibo.api.motan.config.handler.SimpleConfigHandler.buildClusterSupport(SimpleConfigHandler.java:55)
    at com.weibo.api.motan.config.RefererConfig.createClusterSupport(RefererConfig.java:184)
    at com.weibo.api.motan.config.RefererConfig.initRef(RefererConfig.java:128)
    at com.weibo.api.motan.config.RefererConfig.getRef(RefererConfig.java:85)
    at com.weibo.api.motan.config.springsupport.RefererConfigBean.getObject(RefererConfigBean.java:41)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1600)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:187)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1208)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1048)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1018)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:570)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:350)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

@sunnights
Copy link
Collaborator

这个是捕获的代码抛出的异常,异常信息是null,没法定位具体抛异常的位置,需要调试来看代码块中抛异常的具体位置……

@gongrico
Copy link
Author

没有日志么?

@netboynb
Copy link

可能是这种情况 : motan 注册服务使用的是zookeeper临时节点,当网络抖动或者服务端线程堵塞时会导致临时节点丢失,确认下 你获取服务时 在zookeeper上的服务节点是否存在

在 2016年6月19日,下午7:33,Jake Zhang <notifications@github.com mailto:notifications@github.com> 写道:

这个是捕获的代码抛出的异常,异常信息是null,没法定位具体抛异常的位置,需要调试来看代码块中抛异常的具体位置……


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub #120 (comment), or mute the thread https://github.com/notifications/unsubscribe/AFoo5dJa40Cm9Vl8v0Xyw2Y0b31KiQ8fks5qNSkigaJpZM4I5A5P.

@gongrico
Copy link
Author

我电脑里的host文件屏蔽了百度所有的产品
0.0.0.0 baidu.com

对motan有影响么?

@rayzhang0603
Copy link
Collaborator

@gongrico 这个host配置对motan没有影响。错误日志中的cause为原始异常的message信息,这个字段为空说明没有从原始异常中获取到message信息。你可以断点在ZookeeperRegistry类的line:83,看看具体的exception是什么。

     LoggerUtil.info(String.format("[ZookeeperRegistry] subscribe service: path=%s, info=%s", ZkUtils.toNodePath(url, ZkNodeType.AVAILABLE_SERVER), url.toFullStr()));
    } catch (Throwable e) {
        throw new MotanFrameworkException(String.format("Failed to subscribe %s to zookeeper(%s), cause: %s", url, getUrl(), e.getMessage()));
    }

@sunnights
Copy link
Collaborator

请参考#129

@gongrico
Copy link
Author

收到,感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants