This seems to have started some time in the past week, but I am not 100% sure. I am testing with by pulling down the "main", building it, installing locally, and using 4.0.0-SNAPSHOT in my local client.
In this scenario, configure one of the following ways:
- Configure one or more config server URLs under
spring.config.import
. - Or, set up
spring.config.import=configserver:
without URLs. Set one or more URLs viaspring.cloud.config.uri
.
Either of the above scenario produces same issue.
Expected: A spring-cloud-config-client will try connecting only to the configured config server URLs. Observed: The client will try to connect to the default URL "http://localhost:8888" first.
I have attached a sample IntelliJ project that demonstrates the issue. Due to https://github.com/spring-cloud/spring-cloud-config/issues/2051, if you run this as-is, it won't produce a log file, so you can't see the log showing that it is calling localhost. To observe in the logs, update the uri(s) in the application.yml file to point to a real config server and set the application name, password, etc. so that the server will return a 200 and a log will be produced. I will also attach a sample log file.
Note that I was running with Java 17. (Ignore the name of the file in the zipped project that has "Java8".)
ConfigServerClient_CallsLocalhost.zip
Comment From: marnee01
@ryanjbaxter Asked me to try 2021.0.1, also. I will see if I can reproduce it that way.
Comment From: marnee01
I switched spring-cloud.version
to 2021.0.1
and the issue still presented itself.
Comment From: kmartin-bh
I'm also seeing this issue. Did you find any resolution?
Comment From: kmartin-bh
I'm on 2021.0.3
. When defining anything other than the default localhost:8888
using spring.config.import
, it calls my specified server, then it calls localhost:8888
, which fails and the application will not start up.
application.properties
:
spring.application.name=msgw(_)application
spring.config.import=aws-secretsmanager:${ENVIRONMENT}/secret/path,configserver:https://my.server.com
spring.cloud.config.label=${CONFIGURATION_GIT_BRANCH}
spring.cloud.config.username=${username}
spring.cloud.config.password=${password}
Startup logs:
2022-09-01 07:50:58.763 | | restartedMain | INFO | Fetching config from server at : https://my.server.com | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 07:50:58.763 | | restartedMain | INFO | Loading secrets from AWS Secret Manager secret with name: dev/secret/path, optional: false | io.awspring.cloud.secretsmanager.AwsSecretsManagerPropertySources | logTo | 255 |
2022-09-01 07:50:58.763 | | restartedMain | INFO | Fetching config from server at : http://localhost:8888 | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 07:50:58.763 | | restartedMain | INFO | Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 07:50:58.764 | | restartedMain | INFO | Fetching config from server at : http://localhost:8888 | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 07:50:58.764 | | restartedMain | INFO | Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 07:50:58.793 | | restartedMain | ERROR | Application run failed
POM:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
Comment From: kmartin-bh
For reference, I posted this question on SO to try and get some answers. https://stackoverflow.com/questions/73570600/spring-cloud-config-client-tries-localhost8888-in-addition-to-my-specified-serv
Comment From: ryanjbaxter
Can you provide a sample without the AWS pieces that reproduces the issue?
Comment From: kmartin-bh
@ryanjbaxter It's the same example. Using the aws piece or not does not change the behavior.
Comment From: kmartin-bh
I'll remove it and test again, and provide the logs.
Comment From: ryanjbaxter
Please provide a sample zip or git repo not just the logs
Comment From: kmartin-bh
spring.application.name=msgw(_)application
spring.config.import=configserver:https://my.server.com
spring.cloud.config.label=${CONFIGURATION_GIT_BRANCH}
spring.cloud.config.username=${username}
spring.cloud.config.password=${password}
2022-09-01 10:19:58.418 | | restartedMain | INFO | Fetching config from server at : https://my.server.com | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.419 | | restartedMain | INFO | Located environment: name=msgw/application, profiles=[dev], label=prod, version=401ea4bb26f13d49602a30e20997dff088d62934, state=null | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.419 | | restartedMain | INFO | Fetching config from server at : http://localhost:8888 | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.419 | | restartedMain | INFO | Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.419 | | restartedMain | INFO | Fetching config from server at : http://localhost:8888 | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.419 | | restartedMain | INFO | Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available | org.springframework.cloud.config.client.ConfigServerConfigDataLoader | logTo | 255 |
2022-09-01 10:19:58.453 | | restartedMain | ERROR | Application run failed
Comment From: kmartin-bh
I will need to create a new repo to do this - working out of my enterprise repo that is private. I'm sure I can recreate with a basic setup though.
Comment From: kmartin-bh
@ryanjbaxter Well, after I created a small example app, it worked as expected. So now I'm off to determine why my actual client app isn't working.
Comment From: kmartin-bh
Seems my issue was trying to import the aws secret needed to access my server in the same spring.config.import
config as my config server. So I'll just need to inject the username password a different way. I thought I tested without both imports, but I had to wipe my target directory and repackage for it to work.
Comment From: ryanjbaxter
OK I am going to close this for now then.
Comment From: marnee01
This other user resolved their own issue, but I am the OP and have not stated that the issue is resolved for me. I don't think this should have been closed.
Comment From: ryanjbaxter
Can you provide an example to reproduce the issue? If so I will reopen it.
Comment From: marnee01
I provided an example in the original post.
Comment From: ryanjbaxter
Is there a reason why you are using both spring.config.import and spring-cloud-starter-bootstrap? That is the reason you are seeing the two requests.
Comment From: marnee01
You are right. Once I removed that starter, then it called the correct URL. (I had that in there as a relic from testing a change to this project that had to work with the legacy, also. Since it had been working even with the starter for a while during my testing, and then broke one day when I pulled the latest, I hadn't realized the starter was the issue.)
Thanks for the info.
Comment From: raffig
Please note that log4j
library allowing to load log4j configuration files from config server has dependency to the bootstrap starter. I don't know why, but I have filed the issue under:
https://github.com/apache/logging-log4j2/issues/2157