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

Query information about clients that subscribe to the specified service - The returned value does not meet expectations #12940

Open
Myheartwilgn opened this issue Dec 12, 2024 · 11 comments
Assignees
Milestone

Comments

@Myheartwilgn
Copy link

Myheartwilgn commented Dec 12, 2024

Version:2.2.3~2.3.2
BugApi:Nacos Open API Doc -> /nacos/v2/ns/client/service/subscriber/list
Description:Null is returned when ip or port is null
Code:

  @GetMapping("/service/subscriber/list")
  @Secured(action = ActionTypes.READ, resource = "nacos/admin")
  public Result<List<ObjectNode>> getSubscribeClientList(
          @RequestParam(value = "namespaceId", required = false, defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
          @RequestParam(value = "groupName", required = false, defaultValue = Constants.DEFAULT_GROUP) String groupName,
          @RequestParam(value = "ephemeral", required = false, defaultValue = "true") Boolean ephemeral,
          @RequestParam("serviceName") String serviceName, @RequestParam(value = "ip", required = false) String ip,
          @RequestParam(value = "port", required = false) Integer port) {
      Service service = Service.newService(namespaceId, groupName, serviceName, ephemeral);
      Collection<String> allClientsSubscribeService = clientServiceIndexesManager
              .getAllClientsSubscribeService(service);
      ArrayList<ObjectNode> res = new ArrayList<>();
      for (String clientId : allClientsSubscribeService) {
          Client client = clientManager.getClient(clientId);
          Subscriber subscriber = client.getSubscriber(service);
          if (!Objects.equals(subscriber.getIp(), ip) || !Objects.equals(port, subscriber.getPort())) {
              continue;
          }
          ObjectNode item = JacksonUtils.createEmptyJsonNode();
          item.put("clientId", clientId);
          item.put("ip", subscriber.getIp());
          item.put("port", subscriber.getPort());
          res.add(item);
      }
      return Result.success(res);
  }

BugCode:

    if (!Objects.equals(subscriber.getIp(), ip) || !Objects.equals(port, subscriber.getPort())) {
        continue;
    }
@KomachiSion
Copy link
Collaborator

What's your expected?

@Myheartwilgn
Copy link
Author

What's your expected?
when ip or port is null, don't continue.
Now that the subscriber information is actually found, it is filtered out by "equal" when the ip or port is null, resulting in an empty subscriber list returned.

@KomachiSion
Copy link
Collaborator

So you want when ip or port not input, return all subscribers of this service?

@Myheartwilgn
Copy link
Author

So you want when ip or port not input, return all subscribers of this service?

Yes, in fact, according to the interface documentation, it should be

@KomachiSion
Copy link
Collaborator

Maybe add a new param to support when ip or port is null, return all infos. default same with old version.

Or in Nacos 3.0, default change to return all infos when ip or port is null.

@Myheartwilgn
Copy link
Author

Maybe add a new param to support when ip or port is null, return all infos. default same with old version.

Or in Nacos 3.0, default change to return all infos when ip or port is null.

Good!Thanks!

@zhouchunhai
Copy link
Contributor

@i will solve it@

zhouchunhai added a commit to zhouchunhai/nacos that referenced this issue Jan 2, 2025
@zhouchunhai
Copy link
Contributor

I think there is no need to add a new param.
image

zhouchunhai added a commit to zhouchunhai/nacos that referenced this issue Jan 2, 2025
@Myheartwilgn
Copy link
Author

I think there is no need to add a new param. image

That's what I thought. According to the api, it could be empty

@mivljack
Copy link

mivljack commented Jan 3, 2025

Thank you for reaching out. It seems there’s an issue with the query for client subscription information on Cava Menu Dallas. I recommend reviewing the query parameters and ensuring the service logic and data sources are aligned. If the issue persists, please let me know, and we can look into it further.https://cavamenudallas.com/

@Dario-s-j
Copy link

Dario-s-j commented Jan 3, 2025 via email

zhouchunhai added a commit to zhouchunhai/nacos that referenced this issue Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants