DEV Community

ほうき星 for AWS Community Builders

Posted on • Originally published at qiita.com

Trying AWS IoT Core's New GetConnection and ListSubscriptions APIs

This article is a machine translation of the contents of the following URL, which I wrote in Japanese:

AWS IoT Core 単体で MQTT クライアントの接続状態を取得できるようになったので試す #awsIoT - Qiita

はじめに こんにちは、ほうき星 @H0ukiStar です。 本日 AWS IoT Core に以下のようなアップデートがありました。 Posted on: May 28, 2026 Today, AWS IoT Core launches two new MQTT c...

favicon qiita.com

Introduction

Hello, I'm @H0ukiStar.

Today, AWS IoT Core announced the following update.

Posted on: May 28, 2026
Today, AWS IoT Core launches two new MQTT connection management APIs, GetConnection and ListSubscriptions, enabling you to easily access MQTT client connection and subscription information for your Internet of Things (IoT) devices. These APIs help you troubleshoot connectivity issues, monitor client behavior, and audit connection patterns across your device fleet.

https://aws.amazon.com/about-aws/whats-new/2026/05/aws-iot-core-apis-mqtt/

Previously, checking device connection status required using Fleet Indexing or implementing your own state management with features such as Device Shadow. With this update, it is now possible to check device connection status directly using AWS IoT Core alone.

I previously introduced methods for checking connection status using Fleet Indexing and Device Shadow in the following article, so feel free to check it out as well.

AWS IoT Core でモノの接続状態をオンデマンドで取得する2つの方法 #lambda - Qiita

はじめに こんにちは、ほうき星です。 皆さんは、AWS IoT Core に接続した自作 IoT デバイス(Raspberry Pi / ESP32 など)が 「今オンラインなのか、それともオフラインなのか」を確認したいと思ったことはありませんか? 私は自作した IoT ...

favicon qiita.com

Trying It Out

Let's try the new APIs.

At the time of writing, these APIs do not appear to be available in the AWS SDK yet, so the API requests must be signed manually using SigV4.

This time, I used awscurl for signing. You can install it with the following command:

pip install awscurl
Enter fullscreen mode Exit fullscreen mode

You can also retrieve the API endpoint using the AWS CLI as shown below.

aws iot describe-endpoint --endpoint-type iot:Data-ATS

{
    "endpointAddress": "abcd1234567890-ats.iot.ap-northeast-1.amazonaws.com"
}
Enter fullscreen mode Exit fullscreen mode

GetConnection

This API allows you to retrieve information such as the connection status and Keep Alive configuration of a specified MQTT client.

Send the following request using awscurl.

awscurl \
  --service iotdevicegateway \
  --region ap-northeast-1 \
  "https://abcd1234567890-ats.iot.ap-northeast-1.amazonaws.com/connections/<clientId>"
Enter fullscreen mode Exit fullscreen mode

[!WARNING]
For SigV4 signing, you must specify iotdevicegateway as the service name instead of iot.

You can retrieve information such as whether the client is currently connected and when the connection was established.

{
    "connected": true,
    "cleanSession": true,
    "clientId": "clientId",
    "thingName": "thingName",
    "keepAliveDuration": 15,
    "connectedSince": 1780061470032
}
Enter fullscreen mode Exit fullscreen mode

You can also retrieve socket information by adding includeSocketInformation=true.

awscurl \
  --service iotdevicegateway \
  --region ap-northeast-1 \
  "https://abcd1234567890-ats.iot.ap-northeast-1.amazonaws.com/connections/<clientId>?includeSocketInformation=true"
Enter fullscreen mode Exit fullscreen mode
{
    "connected": true,
    "cleanSession": true,
    "clientId": "clientId",
    "thingName": "thingName",
    "sourceIp": "sourceIp",
    "sourcePort": sourcePort,
    "targetIp": "targetIp",
    "targetPort": 8883,
    "keepAliveDuration": 15,
    "connectedSince": 1780061470032
}
Enter fullscreen mode Exit fullscreen mode

ListSubscriptions

This API allows you to retrieve the topics subscribed to by a specified client.

Send the following request using awscurl.

awscurl \
  --service iotdevicegateway \
  --region ap-northeast-1 \
  "https://abcd1234567890-ats.iot.ap-northeast-1.amazonaws.com/connections/<clientId>/subscriptions"
Enter fullscreen mode Exit fullscreen mode

[!WARNING]
For SigV4 signing, you must specify iotdevicegateway as the service name instead of iot.

You can retrieve the topics currently subscribed to by the specified client as shown below.

{
    "nextToken": "",
    "subscriptions": [
        {
            "topicFilter": "$aws/things/<thingName>/shadow/update/delta",
            "qos": 0
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Conclusion

With the newly introduced GetConnection and ListSubscriptions APIs, it is now possible to retrieve MQTT client connection status and subscription information directly from AWS IoT Core.

Previously, checking connection status often required custom implementations using Fleet Indexing, Device Shadow, or Lifecycle Events. With these new APIs, monitoring client state should become much simpler.

Although the APIs do not yet appear to be available in the AWS SDK, they can already be used today by manually signing requests with SigV4.

If you're interested, give them a try.

Top comments (0)