Skip to content
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 Client brushing log #1252

Closed
caojianqiang1984 opened this issue May 22, 2019 · 2 comments
Closed

Nacos Client brushing log #1252

caojianqiang1984 opened this issue May 22, 2019 · 2 comments

Comments

@caojianqiang1984
Copy link

caojianqiang1984 commented May 22, 2019

Which Component
com.alibaba.nacos:nacos-client:1.0.0

Describe the bug
只要请求不存在的服务,就会不断刷日志

To Reproduce
Steps to reproduce the behavior:

注入服务发现客户端

@Autowired
private DiscoveryClient discoveryClient;

偿试获取一个不存在的服务

discoveryClient.getInstances("service-i");

当服务"service-i"不存在或者下线时,客户端就会不断打印如下日志

11:03:47.307 ERROR [] HostReactor.updateServiceNow:278 [NA] failed to update serviceName: DEFAULT_GROUP@@DBB-Applyjava.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance/list after all servers([service.dev.furong.ink:8848]) tried: failed to req API:http://service.dev.furong.ink:8848/nacos/v1/ns/instance/list. code:404 msg: service not found: DEFAULT_GROUP@@service-i
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:380)
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:304)
at com.alibaba.nacos.client.naming.net.NamingProxy.queryList(NamingProxy.java:217)
at com.alibaba.nacos.client.naming.core.HostReactor.updateServiceNow(HostReactor.java:273)
at com.alibaba.nacos.client.naming.core.HostReactor$UpdateTask.run(HostReactor.java:318)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

Additional context
Add any other context about the problem here.
版本号:
Java11 + spring cloud Greenwich.RELEASE + org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:0.9.0.RELEASE

@nacos-bot
Copy link
Collaborator

Hi @caojianqiang1984, we detect non-English characters in the issue. This comment is an auto translation from @nacos-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Nacos Client brushing log

Which Component
com.alibaba.nacos:nacos-client:1.0.0

Describe the bug
As long as you request a service that does not exist, it will continue to log

To Reproduce
Steps to reproduce the behavior:

Inject service discovery client
@Autowired
private DiscoveryClient discoveryClient;
Try to get a non-existent service
discoveryClient.getInstances("service-i");
When the service "service-i" does not exist or goes offline, the client will continuously print the following log.
11:03:47.307 ERROR [] HostReactor.updateServiceNow:278 [NA] failed to update serviceName: DEFAULT_GROUP@@DBB-Applyjava.lang.IllegalStateException: failed to req API:/nacos/v1/ns/instance/list after all servers([service.dev.furong.ink:8848]) tried: failed to req API:http://service.dev.furong.ink:8848/nacos/v1/ns/instance/list. code:404 msg: service not found: DEFAULT_GROUP@@service-i
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:380)
at com.alibaba.nacos.client.naming.net.NamingProxy.reqAPI(NamingProxy.java:304)
at com.alibaba.nacos.client.naming.net.NamingProxy.queryList(NamingProxy.java:217)
at com.alibaba.nacos.client.naming.core.HostReactor.updateServiceNow(HostReactor.java:273)
at com.alibaba.nacos.client.naming.core.HostReactor$UpdateTask.run(HostReactor.java:318)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)

Additional context
Add any other context about the problem here.
version number:
Java11 + spring cloud Greenwich.RELEASE + org.springframework.cloud:spring-cloud-starter-alibaba-nacos-discovery:0.9.0.RELEASE

@nkorange
Copy link
Collaborator

Nacos Java Client的默认行为是查询时会自动订阅该服务,因此当查询一个不存在的服务时,会不停的去轮询该服务,导致大量日志。但是可以在调用时将subscribe参数设为false,这样就不会一直刷日志了

image

如上图所示,用红框中的方法,并将subscribe参数设为fals即可。

不过不幸的是,这需要Spring Cloud Alibaba支持配置这个参数,目前Spring Cloud Alibaba客户端都是使用的默认接口。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants