alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.96k stars 8.34k forks source link

nacos currentServerAddr http://localhost:8848, Connection refused: connect #1504

Closed chuntaojun closed 4 years ago

chuntaojun commented 4 years ago

@lidongdongli commented on Tue Jun 02 2020

问题一: 使用

com.alibaba.cloud
        <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>

单独配置 服务端口 server: port: ${random.int[18000,18999]} spring: application: name: producter cloud: nacos: config: server-addr: 10.10.3.62:8858 discovery: server-addr: 10.10.3.62:8858

但是启动时出现连接8848端口异常,信息如下 16:03:46.975 [main] [] ERROR com.alibaba.nacos.client.config.http.ServerHttpAgent - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out 16:03:48.978 [main] [] ERROR com.alibaba.nacos.client.config.http.ServerHttpAgent - [NACOS SocketTimeoutException httpGet] currentServerAddr:http://localhost:8848, err : connect timed out 16:03:48.978 [main] [] ERROR com.alibaba.nacos.client.config.http.ServerHttpAgent - no available server 16:03:48.978 [main] [] ERROR com.alibaba.nacos.client.config.impl.ClientWorker - [fixed-localhost_8848] [sub-server] get server config exception, dataId=producter, group=DEFAULT_GROUP, tenant= java.net.ConnectException: no available server

此服务提供者工程未配置任何8848端口,为什么去连8848? 另外服务在控制台中可以看到注册成功.

问题二: 消费者调用服务时,出现以下异常, 15:36:07.232 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] [] ERROR com.alibaba.nacos.client.config.http.ServerHttpAgent - [NACOS ConnectException httpPost] currentServerAddr: http://localhost:8848, err : Connection refused: connect 15:36:09.237 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] [] ERROR com.alibaba.nacos.client.config.http.ServerHttpAgent - [NACOS ConnectException httpPost] currentServerAddr: http://localhost:8848, err : Connection refused: connect 15:36:09.237 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] [] ERROR com.alibaba.nacos.client.config.impl.ClientWorker - [fixed-localhost_8848] [check-update] get changed dataId exception java.net.ConnectException: [NACOS HTTP-POST] The maximum number of tolerable server reconnection errors has been reached at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpPost(ServerHttpAgent.java:170) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpPost(MetricsHttpAgent.java:64) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker.checkUpdateConfigStr(ClientWorker.java:386) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker.checkUpdateDataIds(ClientWorker.java:354) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker$LongPollingRunnable.run(ClientWorker.java:521) ~[nacos-client-1.2.1.jar:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_181] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_181] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] 15:36:09.237 [com.alibaba.nacos.client.Worker.longPolling.fixed-localhost_8848] [] ERROR com.alibaba.nacos.client.config.impl.ClientWorker - longPolling error : java.net.ConnectException: [NACOS HTTP-POST] The maximum number of tolerable server reconnection errors has been reached at com.alibaba.nacos.client.config.http.ServerHttpAgent.httpPost(ServerHttpAgent.java:170) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.http.MetricsHttpAgent.httpPost(MetricsHttpAgent.java:64) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker.checkUpdateConfigStr(ClientWorker.java:386) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker.checkUpdateDataIds(ClientWorker.java:354) ~[nacos-client-1.2.1.jar:?] at com.alibaba.nacos.client.config.impl.ClientWorker$LongPollingRunnable.run(ClientWorker.java:521) ~[nacos-client-1.2.1.jar:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_181] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_181] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_181] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]

怀疑与上面问题一异常原因相同. 服务调用正常返回数据.

都是单机环境 nacos server版本NACOS1.3.0-BETA 代码使用springcloud,

chuntaojun commented 4 years ago

cloud 请使用bootstrap.properties或者bootstrap.yaml去配置

Liu1796997299 commented 4 years ago

然而2.2.1版本在bootstrap中指定配置中心也不行,我是降版本解决了

blankhang commented 3 years ago

一车bug 我从早上看样例 服务注册列表都能看到服务 但跨服务调用 各种报错 不是找不到host 就是连接被拒绝我也是醉了 样例一点也不友好 nacos注册中心也是 整半天 默认配置居然是集群 而不是单例 springcloud是真的简单 几分钟就能成功跑起来和跨服务调用 这个nacos是真心难用