MQTT broker
The MQTT broker driver runs an MQTT broker on the YTCC server. Devices and other systems connect to it, publish messages and subscribe to topics, without a separate broker installation. For what all drivers have in common, see How drivers work.
The broker passes messages between its clients. To get the messages into YTCC, add an MQTT client driver that connects to this broker.
Protocol and role
| Role | MQTT broker. Clients connect to YTCC. |
| Version | MQTT 3.1.1 over TCP |
| Listens on | All network interfaces of the server, port 1883 by default |
| Devices | None. The broker is a driver without devices. |
| Driver type | Mqtt server (mqtt_server) |
Parameters
Set these on the driver in Drivers → devices. Changes take effect only after the driver restarts: Apply shows requires a restart, and a strip offers Restart for the driver. While it restarts, all clients are disconnected and reconnect by themselves. Messages and sessions are kept in memory; a restart of the driver clears the retained messages.
| Parameter | Default for a new broker | Meaning |
|---|---|---|
| Port | 1883 | TCP port, 1–65535. |
| Max connections | 10000 | Most clients at the same time. |
| Max payload size | 262144 | Largest message in bytes (256 KB). |
| Allow anonymous | off | Allow clients to connect without a user. |
| Users | one user ytcc with a random password | User names and passwords for clients, as a JSON list: [{"user": "gw1", "password": "…"}]. |
A broker created in the editor starts with Allow anonymous off; keep it off. With Allow anonymous off and no users, no client can connect.
Security
- Users. Give each device or system its own user and password, and the MQTT client driver of YTCC its own user too. Every user can publish and subscribe to every topic, so create a user only for systems that you trust with every topic.
- Passwords. The passwords are part of the driver settings, so restrict who may edit the configuration.
- Network. Keep the broker and its clients in a protected network. The broker listens on every network interface: allow port 1883 (or your port) only from the devices that need it, with the firewall of the server.
Connecting
- Devices connect to
<YTCC server>:1883with their user and password. - YTCC reads the messages with an MQTT client driver: as its device, set Host to the address
of the server (for example
127.0.0.1on the same server), Port to the port of the broker, and Username and Password to a user of the broker.
Diagnostics
| Symptom | Likely cause |
|---|---|
| The broker does not start | The port is used by another program or another broker |
| Clients are refused | Wrong user or password, or Allow anonymous off for a client without a user |
| Clients connect, messages are missing | The message is larger than Max payload size, or the topics differ |
| A change has no effect | The driver has not been restarted |