When I upgraded from 3.0.9 to 3.1.0, I found the following error when starting the project: 当我从3.0.9升级到3.1.0后,启动项目时发现以下报错:
2022-09-06 11:08:17.323 [main] ERROR o.a.d.r.client.ServiceDiscoveryRegistryDirectory - Unsupported protocol rest in notified url: DefaultServiceInstance{serviceName='sys-service', host='192.168.1.55', port=20001, enabled=true, healthy=true, metadata={preserved.register.source=SPRING_CLOUD}}, null from registry 【REGISTRY IP ADDRESS】 to consumer 192.168.1.55, supported protocol: [dubbo, injvm, mock, registry, service-discovery-registry, tri] java.lang.IllegalStateException: Unsupported protocol rest in notified url: DefaultServiceInstance{serviceName='sys-service', host='192.168.1.55', port=20001, enabled=true, healthy=true, metadata={preserved.register.source=SPRING_CLOUD}}, null from registry 【REGISTRY IP ADDRESS】 to consumer 192.168.1.55, supported protocol: [dubbo, injvm, mock, registry, service-discovery-registry, tri] at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.toInvokers(ServiceDiscoveryRegistryDirectory.java:300) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshInvoker(ServiceDiscoveryRegistryDirectory.java:251) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.refreshOverrideAndInvoker(ServiceDiscoveryRegistryDirectory.java:179) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.notify(ServiceDiscoveryRegistryDirectory.java:173) at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.addListenerAndNotify(ServiceInstancesChangedListener.java:235) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:325) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:216) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:184) at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:111) at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:180) at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:124) at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:571) at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65) at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:436) at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToApplicationFirstInvoker(MigrationInvoker.java:244) at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:73) at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:57) at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:243) at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:536) at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:506) at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:488) at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:80) at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74) at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71) at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52) at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java) at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:600) at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:441) at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:295) at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:227) at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:129) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:383) at java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4780) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:363) at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:154) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:111) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:100) at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:45) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) at cc.uncarbon.module.SaasApiApplication.main(SaasApiApplication.java:10)
However port 20001 is the HTTP port of the downstream microservice 然而端口20001是下游微服务的HTTP端口
After tracking the code I found this: 跟踪代码后我发现:
The provider's configuration file does not actively set the rest protocol. This * should be actively added when registering with the registry. There seems to be no usage found in the feature announcement of version 3.1.0, please advise provider的配置文件中并没有主动设置 rest 协议,这个*应该是注册到注册中心时主动添加的。3.1.0版本的feature公告中好像没有发现用法,请指教
code position 代码位置 org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener#getAddresses
code of version 3.0.11 3.0.11代码 https://github.com/apache/dubbo/blob/8354db26cfd5518bfe177d5e12c045ac003cac54/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/event/listener/ServiceInstancesChangedListener.java
原提问者GitHub用户uncarbon97
这个是应用级服务发现与 Spring Cloud 互通的特性。 这个功能生效的前提是当前初始化的接口的应用名在注册中心存在对应的 Spring Cloud 服务。(如 org.apache.DemoService 接口对应 demo-application 应用名,注册中心存在通过 Spring Cloud 注册的 demo-application 应用) Dubbo 会按照 Spring Cloud 的处理方式读取这部分的服务信息,载入到对应所有接口上。
这个异常检测到不支持 rest 协议后回自动忽略这个地址,但是在 3.0 升级到应用级服务发现之后如果存在和 Spring cloud 同名的应用且提供的功能是不一样的最好需要重命名下,否则很容易出现调用错的问题。从日志中看应用名应该都是sys-service。
例子:Dubbo 发布了 demo-application 这个应用,Spring Cloud 也发布了demo-application 这个服务,Spring Cloud 通过 Feign 或者 restTemplate 调用的时候只会识别 demo-application 这个应用,最终流量会错误地调用到 Dubbo 上来(如果这不是预期)
原回答者GitHub用户AlbumenJ
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。