连接到AWS IoT MQTT主题的客户端数量 [英] Number of clients connected to AWS IoT MQTT topic

查看:1601
本文介绍了连接到AWS IoT MQTT主题的客户端数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们开发了一个iOS应用程序,并将应用程序配置为侦听AWS IoT上特定MQTT主题上发布的所有消息。

We developed an iOS application and configured the app to listen to all the messages published on a particular MQTT topic on AWS IoT.

我想知道的是,有没有办法可以提取正在收听该主题的连接设备列表? (我查看了cloudWatch日志,但找不到连接设备的MAC地址等详细信息)。

All I want to know is, is there a way where I can pull a list of connected devices who are listening on that topic ? (I checked the cloudWatch logs and I couldn't find the detailed info like the MAC address of the device connected etc).

另外,我想知道no是否有限制。可以订阅主题的设备。

Also, I want to know if there is limit on the no. of devices that can be subscribed to a topic.

推荐答案

单个主题的设备数量没有限制。服务的主要优点之一 - 它几乎无限扩展。以下是所有 AWS IoT限制的完整列表。

There is no limit to the number of devices on a single topic. One of the major pros for the service - it scales virtually infinitely. Here's a full list of all the AWS IoT Limits.

查询直接从AWS IoT连接的设备数量并不容易。但是有一种方法可以使用来自 AWS保留主题 - 具体如下以下主题:

There's no easy way to query the number of devices connected directly from AWS IoT. But 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}

您可以创建IoT规则,将所有订阅和未订阅的事件从这些保留主题转发到S3,DynamoDB或RDS,以便查询。一个简单的Lambda函数可以在DynamoDB中对取消订阅进行订阅和递减,也可以很好地工作。 ( DynamoDB原子计数器

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"\]
}

这篇关于连接到AWS IoT MQTT主题的客户端数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆