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
Comments
which version you used? |
springboot 3.2.3 |
nacos-server version? |
|
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 @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 |
the latest version is 2.3.2, can you try this version? |
I've get instanceId use 2.3.2 nacos thx |
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):
The text was updated successfully, but these errors were encountered: