question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Is there a way to list all topics any client is subscribed to?

See original GitHub issue

I’d like to know I the broker can get a list of all topics at least one client is subscribed to.

I need to compute some stuff before publishing the data, therefore I’d like to eliminate unnecessary computation.

Imagine that we have several topics the clients can subscribe to and each of these topics is appended with /i where i is an integer 1..n (e.g. topic_a/1, topic_b/50). If no client is subscribed to topic_a/2, there is no reason to compute the data and publish it.

Thanks in advance! 😉

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
robertsLandocommented, Oct 20, 2021

When I publish two (or more) retained messages for the same topic, only the first one is send to new clients, while I want to send only the last (latest) message and forget about the others.

This statement is incorrect. New clients will always get last retained message sent to a specific topic, that’s what a retained message is, when a new one comes it overrides the previous

1reaction
robertsLandocommented, Oct 5, 2021

The script is wrong:

client.on('machine/1/light_indicator/current', (topic, payload) => {
  console.log(topic, ':', payload)
  client.unsubscribe('machine/1/light_indicator/current')
})

Should be

client.on('message', function(topic, message, packet) {
  if (topic === 'machine/1/light_indicator/current') {
    console.log(topic, ':', payload)
    client.unsubscribe('machine/1/light_indicator/current')
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can consumer group remember which all topics it is ...
A better option would be to use a special message field that would tell your consumer clients whether the message is for them...
Read more >
How to get list of subscribed clients per topic? #152 - GitHub
For a chat application I need to get a list of all clients that subscribed to a topic. What is the best way...
Read more >
List clients subscribed to a certain topic in Mosquitto server
No, you can no get list of which clients are subscribed to what out of mosquitto. What is most likely here is that...
Read more >
List the subscribers of an Amazon SNS topic using an AWS SDK
The following code examples show how to retrieve the list of subscribers of an Amazon SNS topic. There's more on GitHub. Find the...
Read more >
Frequently Asked Questions | About NEJM
Which content on NEJM.org is freely available to all without subscription or a ... Who can address any further inquiries or questions about...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found