alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.47k stars 8.19k forks source link

spring cloud aliaba 2.2.6 RELEASE always No provider available from registry #2234

Open zzwangxin opened 2 years ago

zzwangxin commented 2 years ago

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。 We recommend using English. If you are non-native English speaker, you can use the translation software.

各配置版本 spring cloud alibaba.version= 2.2.6.RELEASE, spring boot.version=2.2.13.RELEASE, spring-cloud.version=Hoxton.SR12; nacos:2.0.1 k8s:1.18

容器启动后

服务均注册到nacos,通过nacos管理台也可以查看到注册服务,但是访问时,提示No provider available from registry。

现像1:service服务先启动,api服务后启动,在api服务还没有启动成功并注册到nacos,这时有请求过来,提示No provider available。

现像2:service服务先启动,api服务后启动并完成注册到nacos,正常请求接口,也提示No provider available,这时候需要重启api服务或service服务。

以上问题,很困扰,而且在经常重启时,问题发生会比较频繁,还麻烦作者尽快解决这个问题,给广大it民工们一个稳定的版本,解决燃眉之急。

After container startup

All services are registered with Nacos. You can also view the registered services through the Nacos management console, but when we accessing server, you will be find question no provider available from registry.

q1: the service starts first and the API service starts later. Before the API service is started successfully and registered with Nacos, a request is sent to the server, and you will find problem no provider available.

q2: the service service starts first, then the API service starts and registers with Nacos, a request is sent to the server, and you will find problem no provider available. At this time, you need to restart the API service or service.

The above problems are very troublesome, and the problems will occur more frequently when they are restarted frequently. It is also troublesome for the author to solve this problem as soon as possible and give the majority of it migrant workers a stable version to solve the urgent problem.

lexang commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

LusiferCoder commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

LusiferCoder commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

一直很稳定,应该是你配置问题

zzwangxin commented 2 years ago

配置没有问题,如果有问题,启动后,服务间接口也会调用不通。但是接口是没问题的

lexang commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

一直很稳定,应该是你配置问题

我觉得是dubbo版本的问题 你的Dubbo 版本怎么替换的

lexang commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

一直很稳定,应该是你配置问题

我觉得是dubbo版本的问题 你的Dubbo 版本怎么替换的

dubbo版本 nacos版本

paoyingshidai commented 2 years ago

解决方案:加上这个类

@Component public class DubboRegistryAdapter implements ApplicationListener {

@Override
public void onApplicationEvent(ServiceInstancesChangedEvent event) {
    Collection<Registry> registries = SpringCloudRegistryFactory.getRegistries();

    for (Registry registry : registries) {
        DubboCloudRegistry dubboCloudRegistry = (DubboCloudRegistry) registry;

        dubboCloudRegistry.onApplicationEvent(event);
    }
}

}

guanweiyi commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

一直很稳定,应该是你配置问题

我觉得是dubbo版本的问题 你的Dubbo 版本怎么替换的

dubbo版本 nacos版本

我也想知道怎么单独升dubbo,我升级后引入了其他问题,nacos的元数据变成preserved.register.source=SPRING_CLOUD了

MilkSunshine commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

一直很稳定,应该是你配置问题

请问dubbo版本是用的哪个依赖

KabourWu commented 2 years ago

解决方案:加上这个类

@component public class DubboRegistryAdapter implements ApplicationListener {

@Override
public void onApplicationEvent(ServiceInstancesChangedEvent event) {
    Collection<Registry> registries = SpringCloudRegistryFactory.getRegistries();

    for (Registry registry : registries) {
        DubboCloudRegistry dubboCloudRegistry = (DubboCloudRegistry) registry;

        dubboCloudRegistry.onApplicationEvent(event);
    }
}

}

试了不起作用

MilkSunshine commented 2 years ago

解决方案:加上这个类 @component public class DubboRegistryAdapter implements ApplicationListener {

@Override
public void onApplicationEvent(ServiceInstancesChangedEvent event) {
    Collection<Registry> registries = SpringCloudRegistryFactory.getRegistries();

    for (Registry registry : registries) {
        DubboCloudRegistry dubboCloudRegistry = (DubboCloudRegistry) registry;

        dubboCloudRegistry.onApplicationEvent(event);
    }
}

}

试了不起作用

`public class CustomDubboActiveProbeSubscriptionService implements ApplicationListener {

@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
    DubboServiceMetadataRepository dubboServiceMetadataRepository = event.getApplicationContext().getBean(DubboServiceMetadataRepository.class);
    Set<String> subscribedServices = dubboServiceMetadataRepository.getSubscribedServices();
    if (!ObjectUtils.isEmpty(subscribedServices)) {
        DiscoveryClient discoveryClient = event.getApplicationContext().getBean(DiscoveryClient.class);
        for (String subscribedService : subscribedServices) {
            log.info("主动探测订阅服务:" + subscribedService);
            ServiceInstancesChangedEvent changedEvent = new ServiceInstancesChangedEvent(subscribedService, discoveryClient.getInstances(subscribedService));
            event.getApplicationContext().publishEvent(changedEvent);
        }
    }
}

}`

MilkSunshine commented 2 years ago

解决方案:加上这个类 @component public class DubboRegistryAdapter implements ApplicationListener {

@Override
public void onApplicationEvent(ServiceInstancesChangedEvent event) {
    Collection<Registry> registries = SpringCloudRegistryFactory.getRegistries();

    for (Registry registry : registries) {
        DubboCloudRegistry dubboCloudRegistry = (DubboCloudRegistry) registry;

        dubboCloudRegistry.onApplicationEvent(event);
    }
}

}

试了不起作用

`public class CustomDubboActiveProbeSubscriptionService implements ApplicationListener {

@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
    DubboServiceMetadataRepository dubboServiceMetadataRepository = event.getApplicationContext().getBean(DubboServiceMetadataRepository.class);
    Set<String> subscribedServices = dubboServiceMetadataRepository.getSubscribedServices();
    if (!ObjectUtils.isEmpty(subscribedServices)) {
        DiscoveryClient discoveryClient = event.getApplicationContext().getBean(DiscoveryClient.class);
        for (String subscribedService : subscribedServices) {
            log.info("主动探测订阅服务:" + subscribedService);
            ServiceInstancesChangedEvent changedEvent = new ServiceInstancesChangedEvent(subscribedService, discoveryClient.getInstances(subscribedService));
            event.getApplicationContext().publishEvent(changedEvent);
        }
    }
}

}`

试试这个用SPI加载

MilkSunshine commented 2 years ago

还是想知道dubbo怎么单独升级的,我这边单独升级一直报错

action2013 commented 2 years ago

还是想知道dubbo怎么单独升级的,我这边单独升级一直报错

<properties>
      <spring-boot.version>2.5.5</spring-boot.version>
      <spring-cloud.version>2020.0.4</spring-cloud.version>
      <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>

      <dubbo.version>2.7.14</dubbo.version>
      <nacos.client.version>2.0.3</nacos.client.version>
  </properties>

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--
                解决
                AbstractAnnotationBeanPostProcessor中setClassValuesAsString和setNestedAnnotationsAsMap找不到 #2210:
                https://github.com/alibaba/spring-cloud-alibaba/issues/2210
            -->
            <dependency>
                <groupId>com.alibaba.spring</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>1.0.11</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo</artifactId>
                <version>${dubbo.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-spring-boot-starter</artifactId>
                <version>${dubbo.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-spring-boot-autoconfigure-compatible</artifactId>
                <version>${dubbo.version}</version>
            </dependency>

            <!--Nacos-->
            <dependency>
                <groupId>com.alibaba.nacos</groupId>
                <artifactId>nacos-client</artifactId>
                <version>${nacos.client.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>3.4.12</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
  </dependencies>
</dependencyManagement>
MilkSunshine commented 2 years ago

还是想知道dubbo怎么单独升级的,我这边单独升级一直报错

<properties>
      <spring-boot.version>2.5.5</spring-boot.version>
      <spring-cloud.version>2020.0.4</spring-cloud.version>
      <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>

      <dubbo.version>2.7.14</dubbo.version>
      <nacos.client.version>2.0.3</nacos.client.version>
  </properties>

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!--
                解决
                AbstractAnnotationBeanPostProcessor中setClassValuesAsString和setNestedAnnotationsAsMap找不到 #2210:
                https://github.com/alibaba/spring-cloud-alibaba/issues/2210
            -->
            <dependency>
                <groupId>com.alibaba.spring</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>1.0.11</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo</artifactId>
                <version>${dubbo.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-spring-boot-starter</artifactId>
                <version>${dubbo.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.dubbo</groupId>
                <artifactId>dubbo-spring-boot-autoconfigure-compatible</artifactId>
                <version>${dubbo.version}</version>
            </dependency>

            <!--Nacos-->
            <dependency>
                <groupId>com.alibaba.nacos</groupId>
                <artifactId>nacos-client</artifactId>
                <version>${nacos.client.version}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.zookeeper</groupId>
                <artifactId>zookeeper</artifactId>
                <version>3.4.12</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
  </dependencies>
</dependencyManagement>

突然发现升级还是解决不了当生产者和消费者2个服务在极短的时间内一起启动,导致访问出现no provider

zzwangxin commented 2 years ago

还是没有解决问题啊,作者能不能解决一下@theonefx

haihaiya commented 2 years ago

还是没有解决问题啊,作者不能解决一下@theonefx

原来不止我一个人这样,搞了两天还是找不到问题所在。难道生产者和消费者启动时间要隔一段时间么

haihaiya commented 2 years ago

我nacos版本为2.0.3正常依赖却无法启动,必须添加

com.alibaba.nacos nacos-client 1.4.2

才可以正常运行

haihaiya commented 2 years ago

我也遇到这个问题 很是影响工作效率 一度想放弃不用dubbo了

我没遇到这问题啊,我的版本

Sprnig Boot 2.5.4

Spring Cloud 2020.0.3

Spring Cloud Alibaba 2021.1

Apache Dubbo 2.7.13

nacos 2.0.3

我使用跟你同样的版本但是调用报错无法找到服务

2021-12-15 01:14:29.389 ERROR 18448 --- [nio-8182-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.dubbo.rpc.RpcException: No provider available from registry 121.555.22.198:8848 for service co.zhuwo.HelloService on consumer 192.168.0.102 use dubbo version 2.7.13, please check status of providers(disabled, not registered or in blacklist).] with root cause

org.apache.dubbo.rpc.RpcException: No provider available from registry 121.555.22.198:8848 for service co.zhuwo.HelloService on consumer 192.168.0.102 use dubbo version 2.7.13, please check status of providers(disabled, not registered or in blacklist).
    at org.apache.dubbo.registry.integration.DynamicDirectory.doList(DynamicDirectory.java:168) ~[dubbo-registry-api-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.directory.AbstractDirectory.list(AbstractDirectory.java:99) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.list(AbstractClusterInvoker.java:297) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:262) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.interceptor.ClusterInterceptor.intercept(ClusterInterceptor.java:47) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.support.wrapper.AbstractCluster$InterceptorInvokerNode.invoke(AbstractCluster.java:92) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:93) ~[dubbo-cluster-2.7.13.jar:2.7.13]
    at org.apache.dubbo.registry.client.migration.MigrationInvoker.invoke(MigrationInvoker.java:170) ~[dubbo-registry-api-2.7.13.jar:2.7.13]
    at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:96) ~[dubbo-rpc-api-2.7.13.jar:2.7.13]
    at org.apache.dubbo.common.bytecode.proxy1.sayHello(proxy1.java) ~[dubbo-common-2.7.13.jar:2.7.13]
    at co.zhuwo.DemoController.doSayHello(DemoController.java:27) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_231]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_231]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_231]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_231]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141) ~[spring-web-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1064) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.52.jar:4.0.FR]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.9.jar:5.3.9]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.52.jar:4.0.FR]
github-actions[bot] commented 5 days ago

This issue has been open 30 days with no activity. This will be closed in 7 days.