IoTDataPlane / Client / get_connection

get_connection

IoTDataPlane.Client.get_connection(**kwargs)

Retrieves connection information for the specified MQTT client.

Requires permission to access the GetConnection action.

See also: AWS API Documentation

Request Syntax

response = client.get_connection(
    clientId='string',
    includeSocketInformation=True|False
)
Parameters:
  • clientId (string) –

    [REQUIRED]

    The unique identifier of the MQTT client to retrieve connection information. The client ID can’t start with a dollar sign ($).

    MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.

  • includeSocketInformation (boolean) – Specifies if socket information (sourcePort, targetPort, sourceIp, targetIp) should be included in the GetConnection response. Set to TRUE to include socket information. Set to FALSE to omit socket information. By default, this is set to FALSE. See the developer guide for how to authorize this parameter.

Return type:

dict

Returns:

Response Syntax

{
    'connected': True|False,
    'thingName': 'string',
    'cleanSession': True|False,
    'sourceIp': 'string',
    'sourcePort': 123,
    'targetIp': 'string',
    'targetPort': 123,
    'keepAliveDuration': 123,
    'connectedSince': 123,
    'disconnectedSince': 123,
    'disconnectReason': 'string',
    'sessionExpiry': 123,
    'clientId': 'string',
    'vpcEndpointId': 'string'
}

Response Structure

  • (dict) –

    • connected (boolean) –

      The connection state of the client. Returns true if the client is currently connected, or false if the client is not connected.

    • thingName (string) –

      The name of the thing associated with the principal of the MQTT client, if applicable.

    • cleanSession (boolean) –

      Indicates whether the client is using a clean session. Returns true for clean sessions or false for persistent sessions.

    • sourceIp (string) –

      The IP address of the client that initiated the connection.

    • sourcePort (integer) –

      The client’s source port.

    • targetIp (string) –

      The IP address of the Amazon Web Services IoT Core endpoint that the client connected to. For clients connected to VPC endpoints, this is the private IP address of the network interface the client is connected to.

    • targetPort (integer) –

      The port number of the Amazon Web Services IoT Core endpoint that the client connected to.

    • keepAliveDuration (integer) –

      The keep-alive interval in seconds that the client specified when establishing the connection.

    • connectedSince (integer) –

      Unix timestamp (in milliseconds) indicating when the client connected. Present only when connected is true.

    • disconnectedSince (integer) –

      Unix timestamp (in milliseconds) indicating when the client disconnected. Present only when connected is false. This information is available for 30 minutes after the client disconnects.

    • disconnectReason (string) –

      The reason for the last disconnection, if the client is currently disconnected. See the developer guide for valid disconnect reasons.

    • sessionExpiry (integer) –

      The session expiry interval in seconds for the MQTT client connection. This is configured by the user. This value indicates how long the session will remain active after the client disconnects.

    • clientId (string) –

      The unique identifier of the MQTT client. This is the same client ID that was used when the client established the connection.

    • vpcEndpointId (string) –

      The ID of the VPC endpoint. Present for clients connected to IoT Core via a VPC endpoint.

Exceptions