describeMqSessions

View information about a client's MQTT or MQ API session

The "describeMqSessions" action requires "clientNames" and returns information about the MQ sessions, which may be an MQTT or MQ API session.

 

Request examples

Minimal

{
  "action": "describeMqSessions",
  "params": {
    "clientNames": [
      "myClientIdentifier"
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
 
 

Maximal

{
  "api": "mq",
  "action": "describeMqSessions",
  "params":
  {
    "clientNames": [
      "a unique MQTT or MQ API client name"
    ],
    "includeSubscribedTopics": true,
    "includePublishedTopics": true,
    "includeStats": true
  },
  "apiVersion": "1.0",
  "debug": "max",
  "requestId": "optionalUniqueRequestIdFromTheClient",
  "authToken": "replaceWithAuthTokenFromCreateSession"
} 
 
 

 

Response example

Maximal

{
  "authToken": "bIn7dGR4koiQmx5G8hf1ypnan1U2ZQoiP2r46N5z4WVFmlzTdTZam3JeIiuZ0ryx",
  "result": {
    "data": [
      {
        "clientName": "client1",
"cleanSession": true,
"temporarySession": false, "sessionStatus": "normal", "username": "ADMIN", "ipaddress": "127.0.0.1", "port": 54076, "mqttProtocol": "3.1.1", "keepAliveSeconds": 0, "connectionStatus": "connected", "connectionDateTime": "2025-09-18T20:56:13", "defaultBinaryFormat": "hex", "defaultVariantFormat": "json", "defaultResponseOptions": { "binaryFormat": "hex", "variantFormat": "json", "dataFormat": "objects", "numberFormat": "number" }, "sessionType": "mqApi", "stats": { "minHealthySendRatePerMinute": 1, "maxHealthySendRatePerMinute": 1000, "maxHealthyBacklogRatePerMinute": 1, "minHealthySubscribedTopicFiltersCount": 1, "maxHealthySubscribedTopicFiltersCount": 1000, "sessionHealth": "healthy|unhealthy|offline", "totalMessagesPublished": 0, "publishRatePerMinute": 0, "publishRatePerMinuteLast10Minutes": 0, "publishRatePerMinuteInSession": 0, "publishRatePerHour": 0, "totalMessagesReceived": 0, "receiveMessagesPerMinute": 0, "receiveMessagesPerMinuteLast10Minutes": 0, "receiveMessagesPerMinuteSinceInSession": 0, "receiveMessagesPerHour": 0, "currentDeliveryBacklogged": 0, "deliveryBacklogRatePerMinute": 0, "deliveryBacklogRatePerMinuteLast10Minutes": 0, "deliveryBacklogRatePerMinuteInSession": 0, "deliveryBacklogRatePerHour": 0, "deliveryBacklogRatePerDay": 0 }, "willTopic": "some/Topic/Name/", "willQoS": 2, "willPayload": "This message is sent when client disconnects.", "willRetain": true, "subscriberCount": 0, "subscribedTopics": [], "publishedTopics": [], "metadata": {} }, { "clientName": "client2", "sessionStatus": "normal", "username": "some/Topic/Name/", "ipaddress": "127.0.0.1", "port": 60678, "mqttProtocol": "3.1.1", "keepAliveSeconds": 0, "connectionStatus": "connected", "connectionDateTime": "2025-09-17T16:01:59", "lastFailedConnectDateTime": "2025-09-18T20:56:25", "lastFailedConnectReason": "API session is already in use", "defaultBinaryFormat": "hex", "defaultVariantFormat": "json", "defaultResponseOptions": { "binaryFormat": "hex", "variantFormat": "json", "dataFormat": "objects", "numberFormat": "number" }, "sessionType": "mqApi", "stats": { "minHealthySendRatePerMinute": 1, "maxHealthySendRatePerMinute": 1000, "maxHealthyBacklogRatePerMinute": 1, "minHealthySubscribedTopicFiltersCount": 1, "maxHealthySubscribedTopicFiltersCount": 1000, "sessionHealth": "unhealthy", "totalMessagesPublished": 0, "publishRatePerMinute": 0, "publishRatePerMinuteLast10Minutes": 0, "publishRatePerMinuteInSession": 0, "publishRatePerHour": 0, "totalMessagesReceived": 0, "receiveMessagesPerMinute": 0, "receiveMessagesPerMinuteLast10Minutes": 0, "receiveMessagesPerMinuteSinceInSession": 0, "receiveMessagesPerHour": 0, "currentDeliveryBacklogged": 0, "deliveryBacklogRatePerMinute": 0, "deliveryBacklogRatePerMinuteLast10Minutes": 0, "deliveryBacklogRatePerMinuteInSession": 0, "deliveryBacklogRatePerHour": 0, "deliveryBacklogRatePerDay": 0 }, "subscriberCount": 0, "subscribedTopics": [], "publishedTopics": [], "metadata": {} } ] }, }
 
 

 

Properties

Request properties ("params")

Property Description Default Type Limits (inclusive)

clientNames

The "clientNames" property contains 0 or more "clientName" strings. It is the client identifier (or clientId) in the MQTT protocol. It uniquely identifies an MQ session, which contains information about a client's subscriptions, settings, and queue position of each topic to which the client is subscribed. The FairCom MQ engine stores this information and retrieves it when an MQTT or MQ API client connects.

Connection authorization is done using an account name with a password or a client certificate.

The "clientName" property does not authorize an MQTT or MQ API session. Another authentication technique authorizes the connection, such as an account name and password or a client certificate. Thus, any account may be used to authorize an MQ connection. Each account is assigned to roles that authorize access to specific topics, client names, actions, etc.

The MQ API allows multiple processes to simultaneously use the same client name to manage sessions, subscribe to topics, send messages to topics, and retrieve messages from topics. 

The MQTT protocol allows only one connection per client identifier because each connection is stateful. If another client with the same "clientName" is already connected, the FairCom server disconnects the other client and vice-versa.

Optional with default of "" an array of "clientName" strings 0 or more strings

includePublishedTopics

The "includePublishedTopics" property causes the response to include the "publishedTopics" property, which contains all topics a client's session has published since the session was created, when set to true. To omit the list of published topics, omit this property or set it to false or null.

Optional with default of true Boolean

true

false

includeStats

The "includeStats" property indicates whether or not the "stats" property will be returned in the response.

Optional with default of true Boolean

true

false

includeSubscribedTopics

The "includeSubscribedTopics" property causes the response to include the "subscribedTopics" property, which contains the topics a client's session is currently subscribed to, when set to true. To omit the list of subscribed topics, omit this property or set it to false or null.

Optional with default of true Boolean

true

false

 

Response properties ("result")

Property Description Type Limits (inclusive)

data

The "data" property contains a response message. Its contents are defined by the action. It is an empty array when no results are available. The following is an example of the data property from a code package action.

  "result": {
    "data": [
      {
        "codeId": 6,
        "databaseName": "faircom",
        "ownerName": "admin",
        "codeName": "convertAndCategorizeTemperature",
        "codeVersion": 1,
        "clonedCodeId": 1,
        "codeStatus": "active",
        "codeLanguage": "javascript",
        "serviceName": "javascript",
        "codeType": "module",
        "description": "optional new description",
        "metadata": {},
        "createdBy": "ADMIN",
        "createdOn": "2025-08-25T21:48:38.109",
        "updatedBy": "ADMIN",
        "updatedOn": "2025-08-25T21:48:38.109",
        "comment": "Cloned from convertTemperature",
        "codeFormat": "utf8"
      },
    ]
array of objects The action determines its contents.

data

.cleanSession

The "cleanSession" property is a synonym for "temporarySession" (see "temporarySession"). It exists for name compatibility with MQTT. Use "temporarysession" because its name is more intuitive.

The "cleanSession" property specifies whether or not to clean the session after the client disconnects. When true, the MQ engine resets the current session, and when the client disconnects, the engine removes the session's settings, subscriptions, and message position. Because you normally want the engine to remember your message position between sessions, you rarely set "cleanSession" to true.

Boolean

true

false

data

.clientName

The "Clientname" property uniquely identifies an MQ session. string  

data

.connectionDateTime

The "connectionDateTime" property specifies the date and time when the connection to the session was made. timestamp An ISO 8601 timestamp

data

.connectionStatus

The "connectionStatus" property is returned by the "describeMqSessions" action to indicate if and how a client is connected to an MQ session. It has the following values:

  • "disconnected" indicates no device or software is connected to the MQ session.
  • "connected" indicates a device or software has established a permanent connection to the MQ session.
  • "connectedTemporarily" indicates a device or software has established a temporary connection to the MQ session. When the device or software disconnects, the server removes the data associated with the MQ session.
string

"disconnected"

"connected"

"connectedTemporarily"

data

.defaultBinaryFormat

Defines the default value of "binaryFormat" string One of the following: "base64", "hex", or "byteArray".

data

.defaultResponseOptions

The "defaultResponseOptions" property is a "responseOptions" object that defines a default value for "responseOptions" that is used by default in all other action calls. 

JSON NAV allows you to choose how your program detects errors. By default, all error properties are included in each response – unless you override this behavior as shown in the example.

The example omits the error object in all responses which makes it easier for statically typed languages, such as C, C++, Java, C#, and VB, because they prefer properties to always be present. To help these languages, the "errorCode", "errorMessage", and "errorData" properties are always present whether there is an error or not.

Example

 "defaultResponseOptions": {
      "binaryFormat": "hex",
      "dataFormat": "objects",
      "numberFormat": "number",
      "variantFormat": "json"
    }
object

"binaryFormat"

"dataFormat"

"numberFormat"

data

defaultResponseOptions

.binaryFormat

The "binaryFormat" property designates the format of binary values embedded in JSON strings. See binaryFormat for more details.  string One of the following: "base64", "hex", or "byteArray".

data

defaultResponseOptions

.dataFormat

The "dataFormat" property defines the format of the "data" property. The default format is an array of arrays. The alternative is an array of objects. The default for "dataFormat" can be changed during a "createSession" action by assigning a different value to the "dataFormat" property in "defaultResponseOptions".

There are three different (but similar) versions of the "dataFormat" property:

Two of those versions occur in a request, and another occurs in a response. They all indicate how data is formatted.

  • "dataFormat" in the request in "responseOptions" determines how the "data" property in the response is formatted.
    • Possible values include:
      • "arrays"
        • This is the default and causes the server to return results as an array of arrays, which is the most efficient.
      • "objects"
        • This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.
  • "dataFormat" in the request in the "params" object notifies the server how the "sourceData" property is formatted in the request. This version is rarely used because of the default "autoDetect" behavior.
    • Possible values include:
      • "arrays"
        • This causes the server to return results as an array of arrays, which is the most efficient.
      • "objects"
        • This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.
      • "autoDetect"
        • This is the default, and the server automatically detects the format of the data in the "sourceData" property.
  • "dataFormat" in the response shows the client how the server formatted the "data" property.
    • Possible values include:
      • "arrays"
        • This is the default and causes the server to return results as an array of arrays, which is the most efficient.
      • "objects"
        • This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.
string

"default"

"arrays"

"objects"

data

defaultResponseOptions

.numberFormat

The "numberFormat" property defines the format of JSON numbers. For more details, see "numberFormat"

string

"number"

"string"

data

defaultResponseOptions

.variantFormat

The "variantFormat" property tells the server how to interpret the variant data included in a JSON Action request. For more details, see "variantFormat". string

"json"

"binary"

"string"

"variantObject"

data

.defaultVariantFormat

The "defaultVariantFormat" property sets the default value of the "variantFormat" property when a JSON Action request does not include it.

string

"json"

"binary"

"string"

"variantObject"

data

.ipaddress

The "ipAddress" property specifies the PLC/Equipment IPV4 Address. string A valid IP address

data

.keepAliveSeconds

The "keepAliveSeconds" property specifies how often (in seconds) the broker expects a message to be sent. The server will retain a temporary session as long as the client performs an MQ Message action within the keep alive timeout period, which is "keepAliveSeconds" x 1.5. Once there is no activity, the server starts the session expiry timer to remove the temporary session. If there is no session activity within the number of seconds specified in the "sessionExpiryInternal" property, the server removes the session.

integer No limit

data

.lastFailedConnectDateTime

The "lastFailedConnectDateTime" property specifies the last date and time the connection was interrupted. timestamp An ISO 8601 timestamp

data

.lastFailedConnectReason

The "lastFailedConnectReason" property specifies the reason why the connection was interrupted most recently. string No limit

data

.metadata

The "metadata" property contains user-defined properties that add keywords and tags about the code package. The server indexes this field with a full-text index so you can search for any word or phrase to find code packages. object 0 or more key/value pairs

data

.mqttProtocol

The "mqttProtocol" property specifies the version of MQTT protocol to use in your session. string enum

"3.1.1"

"5.0"

data

.port

The "port" property is an integer that specifies the port number.

integer an integer port number

data

.publishedTopics

The "publishedTopics" property returns a list of the topics the client has published since the session was first created.

string 1 to 65,500 bytes

data

.sessionStatus

The "sessionStatus" property specifies the status of an MQTT or MQ API session as "normal", "hidden", "banned", or "inactive" to hide its visibility in API results and the dashboard views, ban a client from connecting, or mark a client as inactive. A banned session prevents clients from using the session to publish and subscribe to messages. When "sessionStatus" is omitted, it defaults to "normal".

  • "normal" resets a client to its default normal state. The client is not hidden in API results and dashboard views and may connect, publish, and subscribe to messages. The engine preserves all information about the client. Use it to unhide, unban, and activate a client.
  • "hidden" hides a client from most API results and dashboard views while allowing the client to connect, publish, and subscribe to messages. The engine preserves all information about the client. Use it to hide administrative client connections.
  • "banned" prevents a client from connecting in the future while preserving all information about the client. Use it to prevent unwanted clients from connecting again using the session's "clientName" to publish and subscribe to messages.
  • "inactive" marks a client session as inactive while allowing the client to connect, publish, and subscribe to messages. The server does not remove an "inactive" session's data so that historical message data sent and received by the client can continue to be associated with the deleted client. If a client connects to an inactive session, the server changes the session to "normal".
    • Use the "deleteMqSession" action to permanently delete the session which removes all session information. The server can no longer associate sent and received messages with the client. The client can reconnect in the future to establish a new session, but this will create a new session. It is common to permanently delete temporary client connections created during testing and troubleshooting.
string enum

"normal"

"hide"

"ban"

data

.sessionType

The "sessionType" property specifies which type of session the requested client is currently running. string

"mqApi"

"mqtt"

"both"

data

.stats

Contains stats about describeMqSessions. object

"currentDeliveryBacklogged"

"deliveryBacklogRatePerDay"

"deliveryBacklogRatePerHour"

"deliveryBacklogRatePerMinute"

"deliveryBacklogRatePerMinuteInSession"

"deliveryBacklogRatePerMinuteLast10Minutes"

"maxHealthyBacklogRatePerMinute"

"maxHealthySendRatePerMinute"

"maxHealthySubscribedTopicFiltersCount"

"minHealthySendRatePerMinute"

"minHealthySubscribedTopicFiltersCount"

"publishedTopics"

"publishRatePerHour"

"publishRatePerMinute"

"publishRatePerMinuteInSession"

"publishRatePerMinuteLast10Minutes"

"receiveMessagesPerHour"

"receiveMessagesPerMinute"

"receiveMessagesPerMinuteLast10Minutes"

"receiveMessagesPerMinuteSinceInSession"

"sessionHealth"

"totalMessagesPublished"

"totalMessagesReceived"

data

stats

.currentDeliveryBacklogged

     

data

stats

.deliveryBacklogRatePerDay

     

data

stats

.deliveryBacklogRatePerHour

     

data

stats

.deliveryBacklogRatePerMinute

     

data

stats

.deliveryBacklogRatePerMinuteInSession

     

data

stats

.deliveryBacklogRatePerMinuteLast10Minutes

     

data

stats

.maxHealthyBacklogRatePerMinute

The "maxHealthyBacklogRatePerMinute" property sets the maximum number of backlog messages per minute for a healthy session. A backlog message is one the server has not yet published to subscribers. The backlog of a topic grows when the incoming message rate exceeds the outgoing. You can set it to any positive integer or whole number, such as 10 or 0.1. The default value is 0, which sets no upper bound.

A connected session is healthy when its message backlog rate does not exceed the maximum. The "describeMqSessions" action returns the "maxHealthyBacklogRatePerMinute" property and the "sessionHealth" property to report the health of a session.

integer Any positive integer

data

stats

.maxHealthySendRatePerMinute

The "maxHealthySendRatePerMinute" property sets the maximum number of messages per minute for a healthy session. You can set it to any positive integer or whole number, such as 10 or 0.1. The default value is 0, which sets no upper bound.

A connected session is healthy when its message send rate does not exceed the maximum. The "describeMqSessions" action returns the "maxHealthySendRatePerMinute" property and the "sessionHealth" property to report the health of a session.

integer Any positive integer

data

stats

.maxHealthySubscribedTopicFiltersCount

The "maxHealthySubscribedTopicFiltersCount" property sets the maximum number of topic filters for a healthy session. You can set it to any positive integer, such as 10. The default value is 0, which sets no upper bound.

A connected session is healthy when it has subscribed to at most the maximum number of topic filters. The "describeMqSessions" action returns the "maxHealthySubscribedTopicFiltersCount" property and the "sessionHealth" property to report the health of a session.

A topic filter may include MQTT wildcard characters, which allows one topic filter to subscribe to many topics. The "maxHealthySubscribedTopicFiltersCount" property does not limit the number of topics.

integer Any positive integer

data

stats

.minHealthySendRatePerMinute

The "minHealthySendRatePerMinute" property sets the minimum number of messages per minute for a healthy session. You can set it to any positive integer or whole number, such as 10 or 0.1. The default value is 0, which sets no lower bound.

A connected session is healthy when its message send rate exceeds the minimum. The "describeMqSessions" action returns the "minHealthySendRatePerMinute" property and the "sessionHealth" property to report the health of a session.

integer Any positive number

data

stats

.minHealthySubscribedTopicFiltersCount

The "minHealthySubscribedTopicFiltersCount" property sets the minimum number of topic filters for a healthy session. You can set it to any positive integer, such as 10. The default value is 0, which sets no lower bound.

A connected session is healthy when it has subscribed to at least the minimum number of topic filters. The "describeMqSessions" action returns the "minHealthySubscribedTopicFiltersCount" property and the "sessionHealth" property to report the health of a session.

A topic filter may include MQTT wildcard characters, which allows one topic filter to subscribe to many topics. The "minHealthySubscribedTopicFiltersCount" property does not limit the number of topics the wildcards match - rather, it establishes a lower bound on the number of subscribed topic filters an MQ Session is allowed to have.

integer Any positive number

data

stats

.publishRatePerHour

     

data

stats

.publishRatePerMinute

     

data

stats

.publishRatePerMinuteInSession

     

data

stats

.publishRatePerMinuteLast10Minutes

     

data

stats

.receiveMessagesPerHour

     

data

stats

.receiveMessagesPerMinute

     

data

stats

.receiveMessagesPerMinuteLast10Minutes

     

data

stats

.receiveMessagesPerMinuteSinceInSession

     

data

stats

.sessionHealth

The "sessionHealth" property describes the session health. For more details, see "sessionHealth"

enum

"healthy"

"unhealthy"

"offline"

data

stats

.totalMessagesPublished

     

data

stats

.totalMessagesReceived

     

data

.subscribedTopics

The "subscribedTopics" property lists the topics that the specified topic is subscribed to. array No limits

data

.subscriberCount

Specifies the number of subscribers integer Number of subscribers

data

.temporarySession

The "temporarySession" property makes a session temporary or permanent. When set to true, the session is temporary; otherwise, it is permanent.

When true, the MQ engine resets the current session, and when the client disconnects, the engine removes the session's settings, subscriptions, and message position. Because you normally want the engine to remember your message position between sessions, you rarely set "temporarySession" to true.

Use the "temporarySession" property to control session permanency rather than the "cleanSession" property because its name is more intuitive. The server returns an error if you include both and set them to opposite values.

Boolean

true

false

data

.username

The "username" property specifies the name that uniquely identifies the account.  string 1 to 64 bytes

data

.willPayload

The "willPayload" property is required when a will message is present. It contains the payload of the last will message. You can set it to any JSON value, including binary values embedded in a JSON string or array.

JSON  

data

.willQoS

The property "willQoS" is reserved. The server sets it to 2.

integer  

data

.willRetain

When true, “willRetain” tells the FairCom server to send the will message to new subscribers as the first message they receive when subscribing to a topic.

Boolean

true

false

data

.willTopic

The "willTopic" property contains the topic that the FairCom server will use to publish the will message. If you set it to an empty string, "", null, or omit it, the FairCom server will not add the will message to the connection. UTF-8 string