Hi,

I am facing below error when I try to call api from another service using Feign client. All the services are deployed on docker using docker-compose.yml on my local machine(Windows).

admin-service_1 | 2021-09-02 08:51:14.637 ERROR 1 --- [nio-9002-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: csp-user-service] with root cause admin-service_1 | admin-service_1 | com.netflix.client.ClientException: Load balancer does not have available server for client: csp-user-service

Please refer code base for details. Code base - here

I have below services running on docker each running in its own container and are registered on same network. Gateway service(port 9000:9000) Eureka service(port 8998:8998) Spring config service(port 8999:8999) Authorization service(port 9001:9001) Admin service(port 9002:9002) User service(port 9003:9003)

  1. I am able to access below user service api and it works fine http://localhost:9000/api/user-service/user/message?access_token=some_token

  2. Its fails when I try to access Admin service url which call above api internally using Feign client. Error - Load balancer does not have available server for client: csp-user-service http://localhost:9000/api/admin-service/admin/message?access_token=some_token

  3. admin-service.yml (User service also has same file except port, service name and ribbon property name are different) `server: port: 9002

spring: main: allow-bean-definition-overriding: true application: name: admin-service autoconfigure.exclude: - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

-----database properties goes here ------outh properties goes here

eureka: client: enabled: true registerWithEureka: true fetchRegistry: true serviceUrl: defaultZone: http://eureka-service:8998/eureka instance: preferIpAddress: true leaseRenewalIntervalInSeconds: 1 leaseExpirationDurationInSeconds: 2

admin-service-ribbon: ribbon: eureka: enabled: true NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList ServerListRefreshInterval: 1000`

  1. CspAdminServiceApplication.java (Admin service main class) `@ComponentScan(basePackages = "com.csp") @EnableJpaAuditing @EnableEurekaClient @SpringBootApplication @RibbonClient(name = "admin-service-ribbon", configuration = RibbonAutoConfiguration.class) @EnableFeignClients(basePackages="com.csp.admin") public class CspAdminServiceApplication extends Oauth2ResourceServerConfig {

    public static void main(String[] args) { SpringApplication.run(CspAdminServiceApplication.class, args); }

    @Autowired ObjectMapper objectMapper;

    @Override public void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests() .antMatchers("/api-docs", "/*/health").permitAll(); }

}`

  1. CspUserServiceApplication .java (User service main class) `@ComponentScan(basePackages = "com.csp") @EnableJpaAuditing @EnableEurekaClient @RibbonClient(name = "user-service-ribbon", configuration = RibbonAutoConfiguration.class) @SpringBootApplication public class CspUserServiceApplication extends Oauth2ResourceServerConfig {

    public static void main(String[] args) { SpringApplication.run(CspUserServiceApplication.class, args); }

    @Autowired ObjectMapper objectMapper;

    @Override public void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests() .antMatchers("/api-docs", "/*/health").permitAll(); }

}`

I don't understand what am I missing here. Please help me with this.

Thank you!

Comment From: OlgaMaciaszek

Hello, @smitJadhav the Hoxton release train and Ribbon are no longer supported. Please upgrade to a supported version with Spring Cloud LoadBalancer in place of Ribbon and let us know if the issue is still there.

Comment From: smitJadhav

Thanks for reply @OlgaMaciaszek . I will update to spring cloud load balancer. It was my silly mistake in above code sample. Incase if someone faces this issue so posting below.

service name was wrong for feign client. old - @FeignClient(name="csp-user-service") Correct - @FeignClient(name="user-service")

Everything is fine now.