0
votes

I'm config an application using spring cloud eureka. I start my discovery app in the 8761 port and reaching the console in "http://localhost:8761".

So, I start my client application and it's appear in the "Application" page of eureka console.

First question: My client is using "server.port=0" in properties config so the tomcat port is starting in random. How can I reaching my services in client? Example: I have a get request in "/api/stuff", is that possible to access this not using the random port? Suppose I don't know the port!

Second Question: I can start any clients I want, they will start, assuming a random port and register in the cloud server discovery, I can see the log:

"Registering application FLY-CLIENT with eureka with status UP"

But they don't appear in "Application" page of eureka console, why they don't appear?

Thanks!

1

1 Answers

0
votes

If you are using Spring RestTemplate to request the services registered in Eureka you need to make it @LoadBalanced, something like this should do the try:

@LoadBalanced
@Bean
RestTemplate restTemplate() {
    return new RestTemplate();
}

// usage
restTemplate.getForObject("http://your-service-name/api/stuff", StuffResponse.class);

As for the 2nd question, I'm a little confused, as you mentioned earlier in the question that your application appears on Eureka's dashboard. Is this behavior only happening for the "fly-client"?