Reputation: 456
I have a port conflict when starting a service and the configuration service is already running. I'm currently using Spring Boot 1.2.3.RELEASE and Spring Cloud version 1.0.0.RELEASE (tried with 1.0.1.RELEASE, same problem).
If I start the config server in port 8888 and then try to start another service, it will try to start in port 8888 even though I have specified another port. The weird thing is that this does not happen in Mac OS, it does happen in Windows and Linux.
If I start the service and then the configuration server then it all works well. The service is assigned a different port than 8888 and the configuration service port 8888.
I have tried different versions of Spring Cloud and Spring Boot and also different configurations. I tried the suggestions on post but they did not work.
Any ideas on how to solve this?
--
I managed to solve the port conflict by removing the server.port
from the application.yml
in the Config Server and moving it to the bootstrap.yml
. I also removed the server.port
from the application.yml
in the Client Service and moved it to the bootstrap.yml
. Below you can see how the config files look at the moment.
These are the configuration files in Config Service:
bootstrap.yml
server:
port: 8888
info:
name: "Config Service"
spring:
application:
name: config-service
profiles:
active: native
cloud:
config:
enabled: true
server:
git:
uri: <url to config repo>
application.yml
management:
context-path: /admin
info:
configuration: "Read From Config Service application.yml"
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
logging:
level:
com.netflix.discovery: 'OFF'
org.springframework.cloud: 'DEBUG'
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 5
preferIpAddress: false
statusPageUrlPath: /admin/info
healthCheckUrlPath: /admin/health
metadataMap:
hostname: ${vcap.application.application_uris[0]}
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
The configuration in the Client Service is:
bootstrap.yml
server:
port: 0
info:
name: "Client Service"
spring:
application:
name: serviceC
profiles:
active: native
cloud:
config:
enabled: true
failFast: true
env: default
label: master
uri: http://localhost:8888
The application.yml is empty.
Now I have another issue. In Linux the Client is getting the configuration from the application.yml
file in the Config Server (the origin of the port conflict) and in Mac OS it getting it from the configured git repository.
What should be the correct behaviour?
Upvotes: 1
Views: 2545
Reputation: 456
Finally got it working.
The problem was the profiles.active: native
setting. The Configuration Service on Linux was getting the configuration from the local application.yml
. For some reason this setting was not working on Mac OS and the Configuration Service was getting the configuration from the Repo.
In the end I removed the profiles.active: native
setting and moved the common configuration to the Repo. Now all services are getting the common configuration from application.properties
in git.
Upvotes: 2