1
votes

I'm following the pubsub.py example code for AWS IoT using MQTT here. In particular I'm connecting to MQTT using the awsiotsdk.

That example works ok, but it connects to MQTT as a generic client, not as a specific device.

I would like to connect to MQTT to publish and subscribe as a specific device. In particular I want to be able to query for connected devices and see this device show up.

In the demo code I see that --client-id is included. By default it uses a UUID to generate a unique client ID for the demo. I've tried setting the client-id to the thing ARN arn:aws:iot:us-west-2:123456789012:thing/test

What I want/expect to see is the following search show the connected thing. The query comes back empty while the pubsub demo is running. The fact that it's empty tells me that the pubsub example is connecting as an MQTT client, not as a device. How do I connect as a device?

aws iot search-index --query-string connectivity.connected:true
{
    "things": []
}

Note that I have enabled thingConnectivityIndexingMode=STATUS via the AWS CLI.


Additional detail from comments:

From the docs:

When the message broker receives a message published by a device or client, it republishes that message

It appears that I'm always connecting to MQTT (over WSS) as a "client". I don't see how to connect as a "device". The docs are maddeningly unspecific about this point. The pubsub.py example seems to connect as a generic "client", not as a particular "device".

I can and have registered the device via the AWS console or boto3 already.

1
Register your thing and follow the doc docs.aws.amazon.com/iot/latest/developerguide/… . Get started at mqttlab.iotsim.io/awsGambit Support
I've added detail to the question quoting specific details from that page. I've read it over a few times, it doesn't disambiguate between connecting as a "client" vs. a registered "device". The pubsub.py example in the SDK seems to only connect as a "client". I'm left with the same question. How do I connect to MQTT (over WSS) as a "device" not just a generic "client"?David Parks

1 Answers

1
votes

The clientId must equal the Thing name of a Thing registered in the Registry.

The connectivity status data is indexed only for connections where the client ID has a matching thing name.

https://docs.aws.amazon.com/iot/latest/developerguide/aggregation-troubleshooting.html