The port that the eureka-client provides to eureka-server is wrong when the server.port
is defined with ${random.int}
Example: When the server boots up the application port is set to 8050 but the Eureka instance have port 8064
I configured the port to be random:
server.port=${random.int(8500,8599)}
I am expecting the server.port
to be equal to the port on the eureka instance.
Here's a diagram that represents briefly what I am trying to achieve Diagram
To ensure that the Eureka instance port matches the randomly assigned server.port, you can explicitly configure the Eureka instance's port in your application's configuration. Here's how you can do it:
Add the following property to your application.properties :
eureka.instance.nonSecurePort=${server.port}
By setting eureka.instance.nonSecurePort to ${server.port}, you explicitly instruct the Eureka client to use the same port as the one assigned to server.port for registration with the Eureka server.