GithubHelp home page GithubHelp logo

Nacos Instance InstanceId issue about nacos HOT 8 CLOSED

onoeono avatar onoeono commented on June 19, 2024
Nacos Instance InstanceId issue

from nacos.

Comments (8)

KomachiSion avatar KomachiSion commented on June 19, 2024

which version you used?

from nacos.

onoeono avatar onoeono commented on June 19, 2024

springboot 3.2.3
com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2023.0.0.0-RC1
com.alibaba.cloud:spring-cloud-alibaba-commons:2023.0.0.0-RC1
org.springframework.cloud:spring-cloud-commons:4.1.0
org.springframework.cloud:spring-cloud-context:4.1.0
com.alibaba.nacos:nacos-client:2.3.0
jdk17.0.10

from nacos.

KomachiSion avatar KomachiSion commented on June 19, 2024

nacos-server version?

from nacos.

onoeono avatar onoeono commented on June 19, 2024

nacos-server version?
2.0.3

from nacos.

KomachiSion avatar KomachiSion commented on June 19, 2024

nacos-server version?
2.0.3

The old version should have this problem, you can try to upgrade new version, I remember this problem has been fixed.

from nacos.

onoeono avatar onoeono commented on June 19, 2024

nacos-server version?
2.0.3

The old version should have this problem, you can try to upgrade new version, I remember this problem has been fixed.

i upgrade nacos server to 2.2.3 and try to get instanceId, it's still null
here is my simple code

@SpringBootApplication
public class CloudApplication {
	@Autowired
	private NacosDiscoveryProperties nacosDiscoveryProperties;

	public static void main(String[] args) {
		SpringApplication.run(CloudApplication.class, args);
	}

	@Bean
	public NamingService namingService() throws NacosException {
		return NamingFactory.createNamingService(nacosDiscoveryProperties.getServerAddr());
	}
}
@RestController
@RequestMapping("/test")
public class TestController {
        @Autowired
	private NamingService namingService;
	@Value("${spring.application.name}")
	private String applicationName;

        @GetMapping("/unique")
	public Object unique() throws NacosException {
		List<Instance> allInstances = this.namingService.getAllInstances(this.applicationName);
		Instance instance = allInstances.get(0);

		String instanceId = instance.getInstanceId();
		System.out.println("instanceId = " + instanceId);
		return allInstances;
	}
}

here is the response

[
    {
        "ip": "my ip address",
        "port": 7088,
        "weight": 1.0,
        "healthy": true,
        "enabled": true,
        "ephemeral": true,
        "clusterName": "DEFAULT",
        "serviceName": "DEFAULT_GROUP@@cloud-service",
        "metadata": {
            "preserved.register.source": "SPRING_CLOUD"
        },
        "ipDeleteTimeout": 30000,
        "instanceHeartBeatInterval": 5000,
        "instanceHeartBeatTimeOut": 15000
    }
]

and the console output instanceId=null

from nacos.

KomachiSion avatar KomachiSion commented on June 19, 2024

the latest version is 2.3.2, can you try this version?

from nacos.

onoeono avatar onoeono commented on June 19, 2024

the latest version is 2.3.2, can you try this version?

I've get instanceId use 2.3.2 nacos thx

from nacos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.