nacos-group / nacos-group/nacos-sdk-python
python注册的服务,在nacos的服务列表里能看到,但是在java里获取不到实例
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 471
- Forks
- 155
- PR merge metrics
- No merged PRs in 30d
Description
python的注册代码
SERVER_ADDRESSES = "127.0.0.1:8848"
NAMESPACE = "public"
def func():
# no auth mode
client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE)
client.send_heartbeat("python", "127.0.0.1", "5000")
print('send heartbeat')
java的获取代码
@RestController
public class TestController {
@Autowired
DiscoveryClient discoveryClient;
@Autowired
RestTemplate restTemplate;
@GetMapping("/hello")
public String sayHello() throws NacosException {
List<ServiceInstance> list = discoveryClient.getInstances("python");
ServiceInstance instance = list.get(0);
}
}
直接就报空指针了
java.lang.NullPointerException: null
at java.util.HashMap.putMapEntries(HashMap.java:500) ~[na:1.8.0_111]
at java.util.HashMap.putAll(HashMap.java:784) ~[na:1.8.0_111]
at com.alibaba.cloud.nacos.discovery.NacosServiceDiscovery.hostToServiceInstance(NacosServiceDiscovery.java:95) ~[spring-cloud-alibaba-nacos-discovery-2.2.0.RELEASE.jar:2.2.0.RELEASE]
这是什么原因啊?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Python registration snippet and the Java DiscoveryClient.getInstances("python") call, then inspect NacosServiceDiscovery.java at line 95 and reproduce the reported null-pointer stack trace. Done means identifying why the registered service cannot be converted or returned to Java and documenting a compatible registration or discovery setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python, spring
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100