# Connecting via MQTT & STOMP

Managed RabbitMQ queues speak more than AMQP. Once you **enable external DNS** on a queue,
each protocol is reachable on its own dedicated port on the queue's hostname. The exact ports
are shown in the dashboard under **Connect to your queue** — they are unique per instance, so
do not assume RabbitMQ's standard port numbers.

Enabling external DNS also opens the queue's firewall automatically, so external clients can
connect right away — there's no separate firewall rule to add. Turning external access back off
closes that path again.

## Available protocols

| Protocol | Encryption | Notes |
|----------|------------|-------|
| AMQP     | Plaintext  | Default messaging protocol (AMQP 0-9-1) |
| AMQPS    | TLS        | AMQP over TLS |
| MQTT     | Plaintext  | IoT / pub-sub |
| MQTTS    | TLS        | MQTT over TLS |
| STOMP    | Plaintext  | Simple text-oriented messaging |
| STOMPS   | TLS        | STOMP over TLS |

Use the **port shown in your dashboard**, not 1883/8883/61613 — those are the broker's internal
ports. Externally each instance gets its own high-numbered port per protocol.

## Authentication

Anonymous access is disabled. Always supply your username (`admin`) and password. The credentials
are on the queue's detail page.

## Choosing a virtual host (MQTT)

MQTT connections use your instance's configured virtual host by default. To target a *different*
vhost, prefix the username with `vhost:` — for example, username `orders:admin` connects user
`admin` into the `orders` vhost.

## MQTT topics

RabbitMQ's MQTT integration routes through the built-in `amq.topic` exchange. If you bridge MQTT
topics over AMQP, bind against `amq.topic`.

## Example (Python, paho-mqtt, plaintext)

```python
import paho.mqtt.client as mqtt

c = mqtt.Client()
c.username_pw_set("admin", "<password>")
c.connect("<your-host>", <mqtt-port-from-dashboard>)
c.loop_start()
c.publish("demo/topic", "hello")
```

For MQTTS, use the MQTTS port from the dashboard and enable TLS (`c.tls_set()`).

## Example (Python, stomp.py, plaintext)

```python
import stomp

conn = stomp.Connection([("<your-host>", <stomp-port-from-dashboard>)])
conn.connect("admin", "<password>", wait=True)
conn.send(destination="/queue/demo", body="hello")
conn.disconnect()
```

For STOMPS, point the connection at the STOMPS port from the dashboard and enable TLS with
`conn.set_ssl(for_hosts=[("<your-host>", <stomps-port-from-dashboard>)])`.
