Skip to main content

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​

RoleMQTT broker. Clients connect to YTCC.
VersionMQTT 3.1.1 over TCP
Listens onAll network interfaces of the server, port 1883 by default
DevicesNone. The broker is a driver without devices.
Driver typeMqtt 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.

ParameterDefault for a new brokerMeaning
Port1883TCP port, 1–65535.
Max connections10000Most clients at the same time.
Max payload size262144Largest message in bytes (256 KB).
Allow anonymousoffAllow clients to connect without a user.
Usersone user ytcc with a random passwordUser 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>:1883 with 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.1 on the same server), Port to the port of the broker, and Username and Password to a user of the broker.

Diagnostics​

SymptomLikely cause
The broker does not startThe port is used by another program or another broker
Clients are refusedWrong user or password, or Allow anonymous off for a client without a user
Clients connect, messages are missingThe message is larger than Max payload size, or the topics differ
A change has no effectThe driver has not been restarted