Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nacos Instance InstanceId issue #12005

Closed
onoeono opened this issue Apr 23, 2024 · 8 comments
Closed

Nacos Instance InstanceId issue #12005

onoeono opened this issue Apr 23, 2024 · 8 comments

Comments

@onoeono
Copy link

onoeono commented Apr 23, 2024

Describe the bug
Get an instance via NamingService, and the instanceId is null

I also try to add preserved.instance.id.generate=snowflake in nacos properties meta
but instanceId is still null
Expected behavior
when registry to nacos, nacos should generate an unique id for this instance

Actually behavior
instanceId is null

Desktop (please complete the following information):

  • OS: Linux Mint 20.3 Cinnamon
  • Version Spring Cloud version 2023.0.0 Spring Cloud Alibaba version 2023.0.0.0-RC1 Nacos Client version 2.3.0
  • Module naming
  • SDK spring-cloud-starter-alibaba-nacos-discovery
@onoeono onoeono changed the title Nacos Instance InstanceId iuuse Nacos Instance InstanceId issue Apr 24, 2024
@KomachiSion
Copy link
Collaborator

which version you used?

@onoeono
Copy link
Author

onoeono commented Apr 25, 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

@KomachiSion
Copy link
Collaborator

nacos-server version?

@onoeono
Copy link
Author

onoeono commented Apr 29, 2024

nacos-server version?
2.0.3

@KomachiSion
Copy link
Collaborator

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.

@onoeono
Copy link
Author

onoeono commented May 6, 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

@KomachiSion
Copy link
Collaborator

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

@onoeono
Copy link
Author

onoeono commented May 10, 2024

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

I've get instanceId use 2.3.2 nacos thx

@onoeono onoeono closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants