Monitoring client connectivity

Platform Service collects and stores information about client activity such as when a device connects, disconnects, or sends messages. Use the client connection state API to query the activity of one or many device clients.

As an example, you can get information on when a client was last active and why it became disconnected, or you can view all clients that did not connect in the past day so that you can address any issues.

For a detailed description of the API details, see the swagger documentation at the following URL: https://docs.internetofthings.ibmcloud.com/apis/swagger/v0002/clientstate.html#/Client%20Connection%20State/get_clientconnectionstates__clientId

In Maximo Monitor, replace workspaceId with your workspace or tenant ID.

Note: Brief delay might occur between the time that a client connects or disconnects and the time that the connection status from the API reflects the correct status. To receive live notifications over MQTT when a client connects or disconnects, use the device monitoring topic.

Activate and deactivate the client connection state API

You must activate the client connection state API feature before you can start querying.

To find the current activation status for the client connection state feature, use the GET /config/clientstate API call.

If a 403 response is returned, the feature is not active.

Important: Deactivating the feature deletes any stored client activity status documents and all devices must send another update before the connection state can be determined if you reactivate the feature later.

Use one of the two following methods to activate client connection state API:

Query client connection status

With the client connection state API, you can retrieve and query the connection status for any clients that are connected or were earlier connected to Platform Service.

The connection status includes the following information:

Connection state query examples

The following examples illustrate some common connection state queries.

For more information about the API, including all of the available query filters, see the Client Connection State API Swagger document.

Monitoring client connection status

A brief delay might occur between the time that a client connects and the time that the connection status from the API reflects the correct status.

If constant monitoring is required, you can subscribe to the monitor topic to receive live connectivity status updates for the client. For more information, see Subscribing to device status messages.

Limits

The number of stored recent client states is based on the connection type:

Type Stored client states
Applications 100
Gateways 10,000
Devices 1,000,000

Important: Connections that last a long time might eventually be removed as new connections are made.

Troubleshooting client connectivity issues

Platform Service provides a per-device log of connection information, which you can use to diagnose device connectivity problems or to provide more context to the information that is provided by the monitoring topic or connecting status API.

The connection log provides information such as:

The connection log API returns up to the last 10 log messages for the devices.

For more information, see the Connection Logs API Swagger document.

SDKs with client connectivity HTTP APIs are available for Node.js and for Python.