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

1.x client still requests to the server after calling unsubscribe() #7925

Closed
gaofeihang opened this issue Mar 10, 2022 · 0 comments
Closed
Labels
area/Client Related to Nacos Client SDK status/need discuss

Comments

@gaofeihang
Copy link

Describe the bug
1.x client still requests to the server after calling unsubscribe(). The UpdateTask in HostReactor has no way to be stopped.

Expected behavior
After calling unsubscribe() and removing all listeners, the client stops to request to the server and stops to poll /nacos/v1/ns/instance/list. This expected behavior can reduce the QPS and the pressure of the Nacos server in some cases.

Acutally behavior
After calling unsubscribe(), the client is still polling the server. UpdateTask is scheduled in a finally block in the run() method. It can never be stopped.

How to Reproduce
Steps to reproduce the behavior:

  1. Start a 1.4.3 Nacos server
  2. Register an instance as tutorial
  3. Discover the sevice, then sleep for a while(10s)
  4. Call unsubscribe() using the same listener as subscribe() and therefore remove all listeners.
  5. Debug UpdateTask or observe the access log of the sever. The reqeusts to /nacos/v1/ns/instance/list still exist.

Desktop (please complete the following information):

  • OS: macOS Big Sur
  • Version [nacos-server 1.4.3, nacos-client 1.4.3]
  • Module [naming / nacos-client]
  • SDK [original]

Additional context
Codes for reproducing the problem.

NamingService naming = NamingFactory.createNamingService("127.0.0.1:8848");
EventListener listener = event -> {
    if (event instanceof NamingEvent) {
        System.out.println(((NamingEvent) event).getServiceName());
        System.out.println(((NamingEvent) event).getInstances());
    }
};

naming.subscribe("nacos.test.3", listener);

Thread.sleep(1000 * 10);

naming.unsubscribe("nacos.test.3", listener);

Thread.sleep(1000 * 600);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Client Related to Nacos Client SDK status/need discuss
Projects
None yet
Development

No branches or pull requests

2 participants