1

I've read everything: aws-sdk documentation, IoT documentation, console documentation.


There really isn't much else to add:

Is there a way to check if and/or how many are subscriber to AWS IoT topic? Hacky ways?


This question ask something vaguely similar but it's not the same & it doesn't have an answer.

Mark B
  • 183,023
  • 24
  • 297
  • 295
Solo
  • 6,687
  • 7
  • 35
  • 67

1 Answers1

1

There's no easy way to query that information directly from AWS IoT. But since you asked for "hacky ways" there is a way to detect when any device subscribes and unsubscribes from a topic using the message data from AWS Reserved Topics - specifically these topics below:

$aws/events/subscriptions/subscribed/{clientId}
$aws/events/subscriptions/unsubscribed/{clientId}

You could create an IoT rule to forward all subscribed and unsubscribed events from those reserved topics to S3, DynamoDB or RDS to be queryable. A simple Lambda function to increment on subscribes and decrement on unsubscribes within DynamoDB would work really well too. (DynamoDB Atomic Counter)

Also here's what the message body looks like - from Subscribe/Unsubscribe Events:

{
    "clientId": "186b5",
    "timestamp": 1460065214626,
    "eventType": "subscribed" | "unsubscribed",
    "sessionIdentifier": "00000000-0000-0000-0000-000000000000",
    "principalIdentifier": "000000000000/ABCDEFGHIJKLMNOPQRSTU:some-user/ABCDEFGHIJKLMNOPQRSTU:some-user"
    "topics" : \["foo/bar","device/data","dog/cat"\]
}
John Veldboom
  • 2,049
  • 26
  • 29
  • I've figured it out eventually & I decided to go with my own EC2 WebSockets server(s). IoT feels very hacky for web stuff, every step feels like you're going against the grain. – Solo Sep 30 '17 at 02:54
  • There are some stuff that is a little rough around the edges. For us the biggest pro was the scaleability of the service. – John Veldboom Sep 30 '17 at 02:59