spring-cloud-gateway icon indicating copy to clipboard operation
spring-cloud-gateway copied to clipboard

Why spring cloud config client start the port that ran by spring cloud config server

Open szekai opened this issue 2 years ago • 1 comments

Hi, Why the Spring cloud config client start the port that defined in spring.config.import?

I am using spring boot version 2.7.2 and the service is run with webflux.

I configure the config server in http://localhost:8071. And the client service application.yml I add this spring.config.import: optional:configserver:http://localhost:8071

I start the config server and then the client service, and I got this exception

2022-07-25 17:21:53.709 [main] [] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.boot.web.server.PortInUseException: Port 8071 is already in use at org.springframework.boot.web.embedded.netty.NettyWebServer.lambda$start$2(NettyWebServer.java:105) at org.springframework.boot.web.server.PortInUseException.ifCausedBy(PortInUseException.java:103) at org.springframework.boot.web.embedded.netty.NettyWebServer.start(NettyWebServer.java:103) at org.springframework.boot.web.reactive.context.WebServerManager.start(WebServerManager.java:55) at org.springframework.boot.web.reactive.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:40) at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) at com.mbb.dsi.dsitransactionservice.TransactionServiceApplication.main(TransactionServiceApplication.java:16) Caused by: reactor.netty.ChannelBindException: Failed to bind on [0.0.0.0:8071] Suppressed: java.lang.Exception: #block terminated with an error at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:139) at reactor.core.publisher.Mono.block(Mono.java:1731) at reactor.netty.transport.ServerTransport.bindNow(ServerTransport.java:145) at reactor.netty.transport.ServerTransport.bindNow(ServerTransport.java:130) at org.springframework.boot.web.embedded.netty.NettyWebServer.startHttpServer(NettyWebServer.java:145) at org.springframework.boot.web.embedded.netty.NettyWebServer.start(NettyWebServer.java:100) at org.springframework.boot.web.reactive.context.WebServerManager.start(WebServerManager.java:55) at org.springframework.boot.web.reactive.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:40) at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178) at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54) at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) at com.mbb.dsi.dsitransactionservice.TransactionServiceApplication.main(TransactionServiceApplication.java:16) 2022-07-25 17:21:53.709 [main] [] ERROR o.s.b.d.LoggingFailureAnalysisReporter -


APPLICATION FAILED TO START


Description:

Web server failed to start. Port 8071 was already in use.

Action:

Identify and stop the process that's listening on port 8071 or configure this application to listen on another port.

Process finished with exit code 1

szekai avatar Jul 25 '22 09:07 szekai

I found the issues. The server.port=xxxx need to define in the the client properties file that manage by config server. example.

inside client-config-dev.properties, add server.port=8888

Problem solved, but this behavior is a bug? I didn't found it mention in the documentation.

szekai avatar Aug 02 '22 06:08 szekai