alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.83k stars 8.31k forks source link

Spring-Cloud-Alibaba-Nacos:Deploy SpringBoot with war, service registed on Nacos illegal Ip #1794

Closed VINO42 closed 3 years ago

VINO42 commented 3 years ago

Which Component springboot2.3.2+spring-cloud-alibaba2.2.3.RELEASE+SpringCloud-Hoxton-SR8

Describe the bug I deployed an old project with war rebuilded with springboot2.3.2 deployed in war, ,this service registed in nacos , but the registed ip is not correct, it is my localhost eth0 ipv4, this is curious, port is correct.

To Reproduce Steps to reproduce the behavior:

Expected behavior registed in nacos with the tomcat port and the ip should be the machine eth0 ip; such as :172.xx.xx.xx Screenshots below is nacos registed service instance :

image and below is my localhost ipconfigs: image

Additional context use jdk8, build springboot with war nacos regist codes: ` @Slf4j @Component public class NacosListener implements ApplicationListener {

@Autowired
private NacosRegistration registration;

@Autowired
private NacosAutoServiceRegistration nacosAutoServiceRegistration;

@SneakyThrows
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
    int tomcatPort = IPAddressKowalski.getTomcatPort();
    registration.setPort(tomcatPort);
    String host = registration.getHost();
    log.info("[ init nacos listener  host :: {} ]", host);
    nacosAutoServiceRegistration.start();
}

} ` AND THE REGISTED LOG: image

configs in bootstrap.properties: image

when project started , request the nacos endpoint /actuator/nacos-discovery,get the correct configs: image

use annotations : image

VINO42 commented 3 years ago

Is this a bug? it registed in nacos is a illegal ip, so it was not in the network segment with other services . It should not be my localhost ip, it's weird. There is no java applications running on my localhost machine . I had checked.

VINO42 commented 3 years ago

changed to jar