开发者社区 > 云原生 > 正文

nacos配置:java.lang.IllegalArgumentException:没有可用的服务

组件信息

eg. Nacos Discovery, Sentinel Nacos: 1.0.0 spring-cloud.version: Greenwich.SR1 spring-cloud-alibaba-dependencies:0.9.0.RELEASE

描述错误

2019-05-31 09:10:59.418 ERROR 17024 --- [ main] o.s.c.a.n.registry.NacosServiceRegistry : nacos registry, nacos-config-client register failed...NacosRegistration{nacosDiscoveryProperties=NacosDiscoveryProperties{serverAddr='', endpoint='', namespace='', watchDelay=30000, logName='', service='nacos-config-client', weight=1.0, clusterName='DEFAULT', namingLoadCacheAtStart='false', metadata={preserved.register.source=SPRING_CLOUD}, registerEnabled=true, ip='192.168.1.151', networkInterface='', port=8001, secure=false, accessKey='', secretKey=''}},

java.lang.IllegalArgumentException: no server available at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:354) ~[nacos-client-1.0.0.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:304) ~[nacos-client-1.0.0.jar:na] at com.alibaba.nacos.client.naming.net.NamingProxy.registerService(NamingProxy.java:186) ~[nacos-client-1.0.0.jar:na] at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:298) ~[nacos-client-1.0.0.jar:na] at com.alibaba.nacos.client.naming.NacosNamingService.registerInstance(NacosNamingService.java:279) ~[nacos-client-1.0.0.jar:na] at org.springframework.cloud.alibaba.nacos.registry.NacosServiceRegistry.register(NacosServiceRegistry.java:63) ~[spring-cloud-alibaba-nacos-discovery-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.register(AbstractAutoServiceRegistration.java:239) [spring-cloud-commons-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.alibaba.nacos.registry.NacosAutoServiceRegistration.register(NacosAutoServiceRegistration.java:74) [spring-cloud-alibaba-nacos-discovery-0.9.0.RELEASE.jar:0.9.0.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.start(AbstractAutoServiceRegistration.java:138) [spring-cloud-commons-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.bind(AbstractAutoServiceRegistration.java:101) [spring-cloud-commons-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:88) [spring-cloud-commons-2.1.1.RELEASE.jar:2.1.1.RELEASE] at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.onApplicationEvent(AbstractAutoServiceRegistration.java:47) [spring-cloud-commons-2.1.1.RELEASE.jar:2.1.1.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.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:166) [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.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) [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 cn.lygnemo.nacosconfigclient.NacosConfigClientApplication.main(NacosConfigClientApplication.java:15) [classes/:na]

复制再现行为的步骤:

启动nacos-config-client后,报错如上,但是配置能正常读取并且在nacos服务上更新参数后也能正常更新。启动完成后每三十秒报一次错:java.lang.IllegalArgumentException: no server available

提问20.png

附加上下文 e.g. MacOS 、Java8 、 Version 0.2.1.RELEASE

naming-server.log

2019-05-31 10:13:53,221 WARN protect threshold reached, return all ips, service: DEFAULT_GROUP@@nacos-provider

2019-05-31 10:13:53,241 INFO [NACOS-RAFT] datum is changed, key: com.alibaba.nacos.naming.iplist.ephemeral.public##DEFAULT_GROUP@@nacos-provider, value: {"cachedChecksum":"","instanceList":[{"app":"DEFAULT","clusterName":"DEFAULT","enabled":true,"ephemeral":true,"healthy":true,"instanceId":"192.168.1.151#8762#DEFAULT#DEFAULT_GROUP@@nacos-provider","ip":"192.168.1.151","lastBeat":1559268833241,"marked":false,"metadata":{"preserved.register.source":"SPRING_CLOUD"},"port":8762,"serviceName":"DEFAULT_GROUP@@nacos-provider","tenant":"","weight":1}]}

2019-05-31 10:13:54,242 WARN protect threshold reached, return all ips, service: DEFAULT_GROUP@@nacos-provider

2019-05-31 10:13:54,251 WARN protect threshold reached, return all ips, service: DEFAULT_GROUP@@nacos-provider

提问21.png

提问22.png

bootstrap.properties: spring.application.name=nacos-config-client server.port=8001 spring.cloud.nacos.config.server-addr=127.0.0.1:8848

原提问者GitHub用户Nemo1986

展开
收起
白夜行fighting 2023-06-11 10:32:43 383 0
1 条回答
写回答
取消 提交回答
  • 日志显示“nacos注册表,nacos配置客户端注册失败”,请参阅nacos服务器的日志。

    您的配置似乎缺少某些内容。

    NacosRegistration{nacosDiscoveryProperties=NacosDiscoveryProperties{serverAddr='', endpoint='', namespace='', watchDelay=30000, logName='', service='nacos-config-client', weight=1.0, clusterName='DEFAULT', namingLoadCacheAtStart='false', metadata={preserved.register.source=SPRING_CLOUD}, registerEnabled=true, ip='192.168.1.151', networkInterface='', port=8001, secure=false, accessKey='', secretKey=''}},

    Nacos服务器添加为空。

    如果你想使用nacos discovery,请设置spring.cloud.nacos.discovery.server-addr,它与spring.loud.nacos.config.server-addr不同。

    原回答者GitHub用户fangjian0423

    2023-06-11 11:29:57
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载