Skip to content
Start free evaluation

Broker configuration

This page lists what to check when you configure an MQTT broker for the PDComm simulator. Examples use the setting names of Mosquitto 2.1 from mosquitto.conf(5).

Whichever broker you use, the simulator works only if:

Requirement Why
It supports MQTT 5.0. The simulator always connects with protocol level 5.
The listener the simulator uses is plain TCP and accepts anonymous clients. The simulator has no TLS, user name or password settings.
It accepts QoS 1. The simulator publishes and subscribes at QoS 1.
It forwards the Content Type and User Properties unchanged. The simulator subscriber rejects messages without both properties.
Its maximum packet size is larger than your messages. The simulator doesn’t send messages larger than the broker’s Maximum Packet Size.
It lets the simulator publish and subscribe on its topic. Otherwise PUBACK carries 0x87, or messages never arrive.

When the configuration defines no listener at all, Mosquitto 2.x runs in local only mode: it accepts connections on port 1883 from this computer only, and it allows anonymous clients.

As soon as you define a listener yourself, allow_anonymous defaults to false, and the simulator’s connection fails with MQTT broker connection failed: MQTT ConnAck rejected: 135. 135 is 0x87 (Not authorized).

We recommend requiring TLS and certificates from clients on other computers, and opening a plain loopback listener for a simulator on the same computer. With per_listener_settings true, each listener has its own authentication settings:

shared-listeners.conf
# One broker for the PDComm simulator and for remote clients.
# Each listener has its own authentication settings.
per_listener_settings true
# Loopback listener for the simulator on the same host: plain TCP, anonymous.
listener 1883 127.0.0.1
allow_anonymous true
# Network listener for everyone else: TLS with client certificates.
listener 8883
cafile ca.crt
certfile site.crt
keyfile site.key
require_certificate true
use_identity_as_username true
allow_anonymous false
# Publish broker statistics under $SYS every 10 seconds.
sys_interval 10

The certificate files are the ones you create in the Connect through a TLS broker tutorial. If the simulator runs on another computer, give that computer a local broker and connect it through a TLS bridge.

Mosquitto setting Effect on the simulator Observed result
max_packet_size <bytes> Announced as Maximum Packet Size in CONNACK; the simulator doesn’t send larger messages. With max_packet_size 200, a one-field DataSet is published, and a 200-byte String field fails with MQTT publish failed: MQTT session resource limit
max_qos 0 The simulator can’t publish at QoS 1. MQTT publish failed: unsupported MQTT session feature: broker publication capabilities
max_keepalive <seconds> Announced as Server Keep Alive in CONNACK; the simulator sends PINGREQ at that interval. With max_keepalive 4, a PINGREQ every 4 seconds
max_inflight_messages Receive Maximum; no effect, because the simulator publishes one message at a time.
retain_available false No effect, because the simulator doesn’t retain messages.
persistence true No effect on the simulator, which starts a new session on every connection. Other clients keep their sessions and retained messages across restarts.
acl_file Sets read and write permissions per topic; see the next section.

The simulator itself limits MQTT packets to 128 KiB and UADP messages to 64 KiB.

In a Mosquitto acl_file, rules before any user line apply to anonymous clients:

topic read opcua/uadp/data/#
topic write opcua/uadp/data/100/#
Rule Meaning
topic read <filter> May subscribe and receive.
topic write <filter> May publish.
topic readwrite <filter> or topic <filter> May do both.

When a permission is missing, Mosquitto 2.1 behaves like this:

  • No write permission: the broker answers the QoS 1 PUBLISH with PUBACK reason code 0x87. The simulator status shows error MQTT publish refused: 0x87, and acknowledged doesn’t grow. The broker logs Denied PUBLISH from ….
  • No read permission: the broker answers SUBSCRIBE with success (QoS 1 granted) but never delivers the messages. The simulator starts without an error; only received stays the same.
Setting Purpose
log_type all or mosquitto -v Log every packet. Turn it on only while you reproduce a problem.
log_dest stdout, log_dest file <path> Where the log goes
connection_messages true Log connects and disconnects (the default).
sys_interval <seconds> How often the broker publishes statistics under $SYS/broker/…

Verification tools explains how to read the $SYS topics and the logs.