1

I am using Consul for service discovery and both my services are registered with Consul as it is visible in Consul UI.

Consul But when I am trying to use Feign Client from my example service to access an open endpoint available in auth-service I am getting

"com.netflix.client.ClientException: Load balancer does not have available server for client: auth-service".

Auth-Service AuthServiceApplication.java

@EnableDiscoveryClient
@SpringBootApplication
@ComponentScan(basePackages = {"com.learning.*"})
public class AuthServiceApplication {

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

}

bootstrap.yaml

spring:
  application:
    name: auth-service 

Example-Service ExampleService.java


@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(
    basePackages = {"com.learning.feign.*"}
)
@ComponentScan(basePackages = {"com.learning.*"})
public class ExampleService {
    public static void main(String[] args) {
        SpringApplication.run(ExampleService.class, args);
    }
}

AuthFeignClient.java

@FeignClient(
    name = "auth-service"
)
public interface AuthFeignClient {
    @GetMapping({"/testData"})
    ResponseEntity<GetPublicKeyResponse> getTestData();
}

Note: Feign is working fine when I am hardcoding the URL which I don't want to. When I am trying to consume the auth-service end point I am not able to.

enter image description here

Mandar Dharurkar
  • 267
  • 1
  • 5
  • 16
Suchit
  • 60
  • 2
  • 12
  • did u check this https://stackoverflow.com/questions/41401009/load-balancer-does-not-have-available-server-for-client – Mandar Dharurkar Jan 21 '20 at 04:59
  • 1
    Yes, I do. But my requirement is a bit different. I don't want to maintain the list of servers in properties file. I want to use the DiscoveryClient to get the instances from Consul and Feign can use the same to communicate. – Suchit Jan 21 '20 at 05:04
  • Hi, how do you declare your consul server/cluster for discovery (spring.cloud.consul) ? And is your "auth-service" well registered in it ? – Thomas Escolan Jan 22 '20 at 10:17

0 Answers0