Configure these parameters to connect your backend service to the ApsaraMQ for MQTT broker, publish and subscribe to messages, and monitor client status through the cloud SDK for Go.
Connection parameters
| Parameter | Description |
|---|---|
domain | The endpoint of your ApsaraMQ for MQTT instance. Set the value based on your network environment: Public endpoint: <instance-id>-server-internet.mqtt.aliyuncs.com VPC endpoint: <instance-id>-server-internal.mqtt.aliyuncs.com Replace <instance-id> with your instance ID from the Basic Information section of the Instance Details page in the ApsaraMQ for MQTT console. Important Only specific regions support cloud SDK access. For the full list, see SDK access regions. |
port | The connection port. Set the value to 5672. The protocol and port must match. |
instanceId | The ID of your ApsaraMQ for MQTT instance. Find this value on the Instance Details page in the ApsaraMQ for MQTT console. |
accessKey | Your AccessKey ID, created in the Resource Access Management (RAM) console, for identity authentication. For more information, see Obtain an AccessKey pair. |
secretKey | Your AccessKey secret for identity authentication. Required only when signature authentication is used. For more information, see Obtain an AccessKey pair. |
Publish parameters
| Parameter | Description |
|---|---|
mqttTopic | The MQTT topic to publish messages to. You can specify a parent topic or a subtopic. Parent topics must be created in the ApsaraMQ for MQTT console. Subtopics can be specified directly in code without creating them in the console. For more information about the topic hierarchy, see Basic terms. Important If the specified topic does not exist or your account lacks the required permissions, the client fails authentication and is disconnected from the broker. |
Subscribe parameters
| Parameter | Description |
|---|---|
firstTopic | The parent topic to subscribe to. Create this topic in the ApsaraMQ for MQTT console before subscribing. For more information, see Basic terms. Important If the specified topic does not exist or your account lacks the required permissions, the client fails authentication and is disconnected from the broker. Subtopic-level subscriptions are not supported through the cloud SDK. The cloud SDK is designed for backend applications that collect and analyze messages at the parent topic level. |
Client status notification parameters
| Parameter | Description |
|---|---|
gid | The group ID for receiving client status notifications. Create this group in the ApsaraMQ for MQTT console. For more information, see Basic terms. |