apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.47k stars 26.43k forks source link

Dubbo integrated Nacos throw an exception when dubbo service register first time #7154

Closed wltj920 closed 3 years ago

wltj920 commented 3 years ago

Environment

Steps to reproduce this issue

  1. SpringCloud Alibaba project add nacos discovery, nacos config, dubbo dependencies, like this:
    <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
    </dependency>
    <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
    </dependency>
    <dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-dubbo</artifactId>
    </dependency>
  2. Add dubbo configurations like this:
    # Apache Dubbo RPC框架的配置
    # 注意:Dubbo RPC默认使用NIO异步传输,hessian序列化协议,不适合传100K以上的数据
    dubbo:
    scan:
    base-packages: cn.xxxxxx.xxx.xxxx.xxxx.fw7.xxxx.xxx.xxxx.service # Dubbo服务扫描的包
    protocol:
    name: dubbo # 通信协议,支持http等,默认使用dubbo私有协议,NIO异步传输
    port: -1 # -1 表示端口自增
    registry:
    address: nacos://${spring.cloud.nacos.discovery.server-addr}?username=${spring.cloud.nacos.username}&password=${spring.cloud.nacos.password} # 注册中心的地址
    parameters:
      namespace: fw7 # 指定注册中心的命名空间
      group: DUBBO # 注册中心分组
    use-as-config-center: false # 不将注册中心用于配置中心
    use-as-metadata-center: false # 不将注册中心用于元数据中心
    check: false # 启动时不检查注册中心的状态,避免报错
    cloud:
    subscribed-services: "" # 订阅的Dubbo服务,用,分割,默认为*
    consumer:
    check: false # 启动时不检查生产者的状态,防止生产者未启动时启动失败# Dubbo生产环境配置
    provider:
    token: true # 服务提供者要求使用随机Token加密,防止消费者绕过注册中心调用
  3. Write a dubbo service and set a version like this:

    @DubboService(version = "1.0.0")
    public class RpcRegionServiceImpl implements RpcRegionService {
    
    @Autowired
    private RegionService regionService;
    
    @Override
    public RegionDto getRegionById(String id) {
        Region region = regionService.getById(id);
        return Convert.convert(RegionDto.class, region);
    }
    }
  4. Run nacos and project, see exception in console
  5. Restart the project, the exception is gone.
  6. Update the dubbo service version, restart the project, the exception throw again.

Expected Result

The project has no exception throw when dubbo service register nacos first time. And I hope don't add any config in nacos-config-center.

Actual Result

Please see the exception:

2021-01-29 17:11:22.187 ERROR 18068 --- [main] com.alibaba.nacos.client.naming.callServer:617 : [NA] failed to request

com.alibaba.nacos.api.exception.NacosException: caused: Get data failed, key: com.alibaba.nacos.naming.iplist.fw7##DUBBO@@providers:cn.xxxxxx.xxx.xxxx.xxxx.fw7.xxxx.xxx.xxxx.service.RpcRegionService:1.0.0:;
    at com.alibaba.nacos.client.naming.net.NamingProxy.callServer(NamingProxy.java:615)
    at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:526)
    at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:498)
    at com.alibaba.nacos.client.naming.net.NamingProxy.reqApi(NamingProxy.java:493)
    at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:246)
    at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:212)
    at org.apache.dubbo.registry.nacos.NacosRegistry.lambda$doRegister$1(NacosRegistry.java:160)
    at org.apache.dubbo.registry.nacos.NacosRegistry.execute(NacosRegistry.java:583)
    at org.apache.dubbo.registry.nacos.NacosRegistry.doRegister(NacosRegistry.java:160)
    at org.apache.dubbo.registry.support.FailbackRegistry.register(FailbackRegistry.java:240)
    at org.apache.dubbo.registry.ListenerRegistryWrapper.register(ListenerRegistryWrapper.java:57)
    at org.apache.dubbo.registry.integration.RegistryProtocol.register(RegistryProtocol.java:178)
    at org.apache.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:214)
    at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:62)
    at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:153)
    at org.apache.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:64)
    at org.apache.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java)
    at org.apache.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:492)
    at org.apache.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:325)
    at org.apache.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:300)
    at org.apache.dubbo.config.ServiceConfig.export(ServiceConfig.java:206)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.lambda$exportServices$15(DubboBootstrap.java:1103)
    at java.base/java.util.HashMap$Values.forEach(HashMap.java:976)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.exportServices(DubboBootstrap.java:1090)
    at org.apache.dubbo.config.bootstrap.DubboBootstrap.start(DubboBootstrap.java:901)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onContextRefreshedEvent(DubboBootstrapApplicationListener.java:59)
    at org.apache.dubbo.config.spring.context.DubboBootstrapApplicationListener.onApplicationContextEvent(DubboBootstrapApplicationListener.java:52)
    at org.apache.dubbo.config.spring.context.OneTimeExecutionApplicationContextEventListener.onApplicationEvent(OneTimeExecutionApplicationContextEventListener.java:40)
...
AlbumenJ commented 3 years ago

would this an issue for nacos ?

wltj920 commented 3 years ago

would this an issue for nacos ?

Thanks for reply. I wrote an issue for nacos by your suggestion(Nacos Issue #4836), looking forward to their answer.

wltj920 commented 3 years ago

Nacos will fix this problem in 2.0.0