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.