Open ouyangyaxiong opened 6 years ago
@rayzhang0603
可以参考这个看看 https://github.com/weibocom/motan/issues/656 看看心跳开关是否打开,看看server端是否已经在consul上正确注册了
端口号为0是对的,你追查下日志输出的refUrl的来源就知道了,这个refUrl是motan自己构造用来标识一个服务引用的url,真正的服务的url是从服务注册中心发现的url。客户端引用不到服务,你应该去注册中心查一查对应的服务是否已经成功注册上去了
服务端注册成功信息: com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:59) NettyEndpointFactory create share_channel server: url=motan2://192.168.99.102:8002/com.yks.demo.project.service.BookService?group=motan-demo-rpc com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:55) NettyServer ServerChannel start Open: url=motan2://192.168.99.102:8002/?group=motan-demo-rpc com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:55) add resource class com.weibo.api.motan.util.StatsUtil$2 to list com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:55) NettyServer ServerChannel finish Open: url=motan2://192.168.99.102:8002/?group=motan-demo-rpc com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:55) DefaultRpcExporter node init Success: [DefaultRpcExporter] url=motan2://192.168.99.102:8002/com.yks.demo.project.service.BookService?group=motan-demo-rpc com.weibo.api.motan.log.DefaultLogService.info(DefaultLogService.java:55) MotanV2Protocol export Success: url=motan2://192.168.99.102:8002/com.yks.demo.project.service.BookService?group=motan-demo-rpc
客户端错误: Caused by: com.weibo.api.motan.exception.MotanFrameworkException: error_message: ClusterSupport No service urls for the refer:motan2://192.168.99.102:0/motan-demo-rpc/com.yks.demo.project.service.BookService/1.0/referer, registries:[zookeeper://172.30.85.115:2181/com.weibo.api.motan.registry.RegistryService?group=default_rpc], status: 404, error_code: 10101,r=null at com.weibo.api.motan.cluster.support.ClusterSupport.init(ClusterSupport.java:105) at com.weibo.api.motan.config.handler.SimpleConfigHandler.buildClusterSupport(SimpleConfigHandler.java:54) at com.weibo.api.motan.config.RefererConfig.createClusterSupport(RefererConfig.java:196) at com.weibo.api.motan.config.RefererConfig.initRef(RefererConfig.java:138) at com.weibo.api.motan.config.RefererConfig.getRef(RefererConfig.java:94) at com.weibo.api.motan.config.springsupport.RefererConfigBean.getObject(RefererConfigBean.java:44) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ... 6 more
服务端暴露的是 motan2://192.168.99.102:8002 ,而客户端的referurl是motan2://192.168.99.102:0,端口号变成0了?
RefererConfig.java中构造refUrl的代码:
URL refUrl = new URL(protocol.getName(), localIp, MotanConstants.DEFAULT_INT_VALUE, path, params); ClusterSupport<T> clusterSupport = createClusterSupport(refUrl, configHandler, registryUrls);
这里为什么是写死的 MotanConstants.DEFAULT_INT_VALUE(0)端口号 如何解决上面报错问题?