To use the MQTT protocol a central broker has to exist. All the connection handling, message forwarding, buffering and re-delivering (at network interrupts) are managed by the MQTT broker. All MQTT clients communicate with each other only via the broker.
In general, there are two alternatives to running the broker:
- to use some existing, public broker service (f.e. cloud broker):
- more secure to use over the Internet (no need to open network for incoming TCP connections)
- somewhat easier to start with - all broker setup and maintenance is done by the third-party (service provider)
- to set up and use system own, private broker:
- settings, reliability and security are more under system owner control
- no sign-up nor agreements needed by third parties (service providers)
CDP has a simple MQTT broker component built in.
To use CDP built-in MQTT broker MQTTBroker subcomponent must be added to CDP application.
MQTTBroker has the following configurable properties:
|Address broker listens on (IP or hostname). Use '0.0.0.0' to listen on all network interfaces.
|TCP port broker listens on (recommended values are 1883 for unencrypted and 8883 for encrypted connections)
|Broker connection encryption. Choose between options:
|Broker CA certificate file name for TLS encryption. See also TLS certificate setup.
|Client authentication certificate file name (for TLS client authentication). See also TLS certificate setup.
|Broker key file name for TLS encryption (PEM certificate or PSK list). See also TLS certificate setup and TLS-PSK key setup
|When set to true, then every client connecting to the broker must provide a valid (i.e. signed by the broker CA) certificate for the connection to be allowed
|This option sets the maximum number of topic aliases that a MQTT v5 client is allowed to create. Defaults to 10 but can be increased up to 65535. Can be set to 0 to disallow the topic aliases feature from being used.
|When set, then the connection, subscription and retainable payload data will be written to the disk database specified in the PersistenceLocation. When the broker is restarted, it will reload the information stored in that database. The data will be written to disk when the broker suspends and also at intervals as defined by the PersistenceSaveInterval and PersistenceSaveOnChanges. If unset, no persistence is used and the data will be stored in memory only and will be lost on broker stop.
|The database file name to use for the persistence database, with the optional path prefix, relative to the application folder
|Specifies the persistence database write interval: when PersistenceSaveOnChanges is unset, then it is treated as the interval of seconds that the broker will wait between each time it saves the in-memory database to PersistenceDatabase. When PersistenceSaveOnChanges is set, then this value is treated as the number of subscription changes to wait before they have to be saved to the database. If set to 0, the in-memory database will only be saved when the broker shuts down.
|When set, the broker will count the number of subscription changes, retained messages received and queued messages and if the total exceeds PersistenceInterval, then the in-memory database will be saved to disk. When unset, then the PersistenceInterval is treated as a time in seconds.