failed to req API:test.xxxx.com:8848/nacos/v1/ns/instance. code:500 msg: java.net.SocketException: C

报错:

java.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance after all servers([test.xxxx.com:8848]) tried: failed to req API:test.xxxx.com:8848/nacos/v1/ns/instance. code:500 msg: java.net.SocketException: Connection reset
        at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:464) ~[nacos-client-1.1.1.jar!/:?]
        at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:386) ~[nacos-client-1.1.1.jar!/:?]
        at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:188) ~[nacos-client-1.1.1.jar!/:?]
        at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:205) ~[nacos-client-1.1.1.jar!/:?]
        at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:184) ~[nacos-client-1.1.1.jar!/:?]
        at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:61) [spring-cloud-alibaba-nacos-discovery-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:219) [spring-cloud-commons-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at com.alibaba.cloud.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:74) [spring-cloud-alibaba-nacos-discovery-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:118) [spring-cloud-commons-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.bind(AbstractAutoServiceRegistration.java:82) [spring-cloud-commons-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:69) [spring-cloud-commons-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:32) [spring-cloud-commons-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.java:124) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) [spring-context-5.1.7.RELEASE.jar!/:5.1.7.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:67) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.5.RELEASE.jar!/:2.1.5.RELEASE]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_201]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_201]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_201]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [app.jar:1.0.21]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [app.jar:1.0.21]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [app.jar:1.0.21]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [app.jar:1.0.21]

nacos定义

Nacos注册中心的原理:

服务注册:微服务在启动时会通过其集成的高性能Nacos客户端向Nacos注册中心发送注册请求。请求包括服务名称、IP地址、端口号等基本信息。Nacos注册中心负责将这些信息保存在数据库中,并在服务端建立相应的连接记录。
服务发现:当微服务需要调用另一个微服务时,它会向Nacos注册中心发出请求,获取目标服务的元数据,如服务名称、IP地址和端口号。Nacos注册中心负责将这些信息转发给微服务,以便进行通信。

健康检查:为了确保服务的稳定性,Nacos客户端会在定期的时间间隔内向Nacos注册中心发送心跳请求。如果长时间未收到回复,Nacos注册中心可能会将服务标记为不可用。
集群和高可用性:Nacos支持分布式部署和集群高可用性。它可以在多个节点间共享注册信息和配置信息,并通过自动故障转移机制保证服务的持续可用性。

数据模型:Nacos采用了一种三层数据模型,包括服务、集群和实例。这种设计允许对不同级别的资源进行管理和控制,同时也提供了数据隔离和安全性保障。

服务实例的生命周期管理:Nacos在服务实例上存储健康状态、权重等属性,并根据这些信息动态调整服务实例的管理策略。

数据一致性和隔离:Nacos的设计注重数据的一致性和隔离,以适应不同用户。

检查nacos是否启动

页面输入:
ip:8848/nacos/index.html#/serviceManagement?name=test&groupName=DEFAULT_GROUP&dataId=&group=&namespace=&appName=

如果页面能够显示如下:
在这里插入图片描述
这个表示nacos可以进行对外服务。

检查微服务

在这里插入图片描述

看看服务中微服务数量
在这里插入图片描述
是否有缺失。
如果缺失就docker重新启动。
都没有问题,就可以ok对外服务了。