Closed jiehuaou closed 3 years ago
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<!-- <version>2.3.3.RELEASE</version>-->
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>client-lb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>client-lb</name>
<description>Demo LB Client for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<!-- <spring-cloud.version>Hoxton.SR12</spring-cloud.version>-->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
please note the version:
< version >2.5.4< / version > < ! -- < version>2.3.3.RELEASE< / version> -- >
and
< spring-cloud.version>2020.0.3</spring-cloud.version >
< ! --
application.yml
spring:
cloud:
...
loadbalancer:
health-check:
refetch-instances: true
refetch-instances-interval: 2s
# repeat-health-check: true
# interval: 10s
ribbon:
enabled: false
cache:
ttl: 2s
enabled: true
I just meet this issue and search solution, could you tell me how did you solve this issue? thanks
Describe the bug ... o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: data-service-1 ... spring cloud load-balancer does not work in spring boot 2.5.x with Spring cloud version 2020.0.X spring cloud load-balancer can not fetch service instance list
Sample 1) I have a service "data-service-1" running and registered in consul which I can verify it by checking http://localhost:8500/ui, 2) now I launch my client service which internally invoke "data-service-1" , with sample code here:
the load-balancer can work well in spring boot 2.3.3 with Spring cloud version Hoxton.SR12, even can handle the case when some instance are Up or down, such as re-fetch latest UP instance then route call to it,
but when I change the version to spring boot 2.5.4 with Spring cloud version 2020.0.3 , it just simply gives warning :
2021-09-16 11:16:15.385 WARN 21040 --- [ctor-http-nio-1] o.s.c.l.core.RoundRobinLoadBalancer : No servers available for service: data-service-1
here is sample code : https://github.com/jiehuaou/discovery-client-lb
thanks, Albert