Your first MQTT connection
Connect to CloudSignal and send your first message using MQTTX or the command line.
This guide walks you through connecting to CloudSignal and sending your first message.
Prerequisites
Before starting, you need:
- A CloudSignal account. Sign up if you haven't already.
- An MQTT user. See Create MQTT user.
- Your organization ID. Found in Settings → Organization.
Connection details
| Parameter | Value |
|---|---|
| MQTT over TLS | mqtts://mqtt.cloudsignal.app:8883 |
| MQTT over WSS | wss://connect.cloudsignal.app:18885/ |
| Username | your_username@your_organization_id |
| Password | The password you set when creating the user |
The username must include @organization_id. Just username alone won't work.
Option 1: Using MQTTX (recommended)
MQTTX is a free, cross-platform MQTT client with a graphical interface.
Download and install MQTTX
Download from mqttx.app for Windows, macOS, or Linux.
Create a new connection
- Click the + button to create a new connection.
- Fill in the connection details:
| Field | Value |
|---|---|
| Name | CloudSignal |
| URL | mqtts://mqtt.cloudsignal.app:8883 |
| SSL/TLS | Enabled |
| Username | myuser@abc123-org-id |
| Password | your-password |
- Click Connect.
Subscribe to a topic
- In the subscription panel, enter
chat/lobby/#. - Click Subscribe.
You're now listening for messages on all topics under chat/lobby/.
Publish a message
- In the message panel:
- Topic:
chat/lobby/messages - Payload:
Hello, CloudSignal!
- Topic:
- Click Publish.
You should see your message appear in the received messages panel.
Option 2: Using the Mosquitto CLI
If you prefer the command line:
Install Mosquitto clients
On macOS:
brew install mosquittoOn Ubuntu or Debian:
sudo apt-get install mosquitto-clientsOn Windows, download from mosquitto.org.
Subscribe to a topic
Open a terminal and run:
mosquitto_sub -h mqtt.cloudsignal.app -p 8883 \
-u "myuser@abc123-org-id" \
-P "your-password" \
-t "chat/lobby/#" \
--capath /etc/ssl/certsThis terminal displays incoming messages.
Publish a message
Open a second terminal and run:
mosquitto_pub -h mqtt.cloudsignal.app -p 8883 \
-u "myuser@abc123-org-id" \
-P "your-password" \
-t "chat/lobby/messages" \
-m "Hello from CLI!" \
--capath /etc/ssl/certsYou should see the message appear in your subscriber terminal.
Option 3: Using code
JavaScript / Node.js
const mqtt = require('mqtt');
const client = mqtt.connect('mqtts://mqtt.cloudsignal.app:8883', {
username: 'myuser@abc123-org-id',
password: 'your-password',
});
client.on('connect', () => {
console.log('Connected!');
// Subscribe
client.subscribe('chat/lobby/#');
// Publish
client.publish('chat/lobby/messages', 'Hello from Node.js!');
});
client.on('message', (topic, message) => {
console.log(`${topic}: ${message.toString()}`);
});Python
import paho.mqtt.client as mqtt
import ssl
def on_connect(client, userdata, flags, rc):
print("Connected!")
client.subscribe("chat/lobby/#")
client.publish("chat/lobby/messages", "Hello from Python!")
def on_message(client, userdata, msg):
print(f"{msg.topic}: {msg.payload.decode()}")
client = mqtt.Client()
client.username_pw_set("myuser@abc123-org-id", "your-password")
client.tls_set(cert_reqs=ssl.CERT_REQUIRED)
client.on_connect = on_connect
client.on_message = on_message
client.connect("mqtt.cloudsignal.app", 8883)
client.loop_forever()Verify in dashboard
After connecting, you can verify in the CloudSignal dashboard:
- Go to Sessions → Active Sessions.
- You should see your connected client.
- Check the client ID, username, and IP address.
Troubleshooting
"Connection refused"
- Verify you're connecting to
mqtts://mqtt.cloudsignal.app:8883(native clients) orwss://connect.cloudsignal.app:18885/(browser clients). - Check that TLS is enabled if using port 8883.
"Not authorized" or "Bad username or password"
- Verify the username includes
@organization_id. - Double-check the password.
- Ensure the MQTT user exists and is active.
"Connection timeout"
- Check your internet connection.
- Verify the hostname is correct.
- Try a different port.
Can't see messages
- Make sure you subscribed before publishing.
- Check that the topic patterns match.
- Verify ACL rules allow access to the topic.
Next steps
Now that you're connected:
- Set up ACL rules - Control topic access
- Explore quickstarts - Integrate with your framework
- Learn about QoS - Understand delivery guarantees