Search code examples
netflix-eurekapcf

Eureka Client Service not reachable on PCF Dev


Its my first micro-service using PCF Dev. I have created the following Eureka Server App.

@EnableEurekaServer
@SpringBootApplication
public class EurekaServiceApplication {

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

Below are the properties for the eureka-server service

eureka-service.register-with-eureka=false
eureka-service.fetch-registry=false
eureka-service.defaultZone=http://eureka-service.local.pcfdev.io/
eureka-service.logging.level.com.netflix.eureka=OFF
eureka-service.logging.level.com.netflix.discovery=OFF

Below is the eureka-client service

@EnableDiscoveryClient
@SpringBootApplication
public class EurekaClientApplication {

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

@RestController
class ServiceInstanceRestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping("/service-instances/{applicationName}")
    public List<ServiceInstance> serviceInstancesByApplicationName(@PathVariable String applicationName) {
        return this.discoveryClient.getInstances(applicationName);
    }
}

Below are the properties for the eureka-client service

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.defaultZone=http://eureka-client.local.pcfdev.io/
eureka.client.logging.level.com.netflix.eureka=ON
eureka.client.logging.level.com.netflix.discovery=ON

I have deployed the micro-services on PCF Dev instance running on my local

PCF Dev Snapshot

When I run the server & client as Java applications on my local, I can see the response coming from the service-instances/eureka-client endpoint. But I get an empty array when I am trying invoke the following endpoint

http://eureka-client.local.pcfdev.io/service-instances/eureka-client

When I try to access the eureka-service, using the URL

http://eureka-service.local.pcfdev.io/

I get the following response:

This site can’t be reached eureka-service.local.pcfdev.io refused to connect.
Search Google for eureka service local pcfdev io
ERR_CONNECTION_REFUSED

Thanks in advance.

Edit-1:

As per @Barath's comment, I modified the application.properties file for the client application as below but the issue has not still gone. Earlier, I was wrongly referring the client application name in the application.properties file.

eureka-client.register-with-eureka=true
eureka-client.fetch-registry=true
eureka-client.serviceUrl.defaultZone=http://eureka-client.local.pcfdev.io/
eureka-client.logging.level.com.netflix.eureka=ON
eureka-client.logging.level.com.netflix.discovery=ON

The bootstrap.properties file for client has the following entry:

spring.application.name=eureka-client 

The bootstrap.properties file for server has the following entry:

spring.application.name=eureka-service

Edit-2

Server: https://github.com/abnig/eureka-service Client: https://github.com/abnig/eureka-client


Solution

  • properties to be defined in eureka server and client are described as below

    eureka-server

    eureka:
      instance:
        hostname: eureka-service.local.pcfdev.io
      client:
        fetch-registry: false
        register-with-eureka: false
    

    eureka-client

    eureka:
      client:
        serviceUrl:
          defaultZone: https://eureka-service.local.pcfdev.io/eureka
        register-with-eureka: true
        fetch-registry: true
    

    please refer spring-cloud-native for reference