Defining the "enforcement" in the MQTT connection

76 views Asked by At

I am trying to publish a payload to a MQTT topic defined in the MQTT connection. However, I get this error in the enforcement log: -

Ran into a failure when enforcing incoming signal: The configured filters could not be matched against the given target with ID 'mqttTestTopic'. Either modify the configured filter or ensure that the message is sent via the correct ID. ...

What is required: -

"enforcement": {
                    "input": "{{ source:address }}",
                    "filters": [
                        "'"${TTN_APP_ID}"'/devices/{{ thing:name }}/up"
                    ]
                }

What I have tried: -

"enforcement": {
                    "input": "mqttTestTopic",
                    "filters": [
                        "mqttTestTopic/org.eclipse.ditto.testing.demo:digital-twin"
                    ]
                }

I am confused about what must be defined in the input and filters. Can I get more clarification?

1

There are 1 answers

0
Thomas Jäckle On

If you don't need the Source enforcement, you can simply leave that configuration away.

You would only need to configure it, if you want to e.g. ensure that a device may only update its "twin" (or thing in Ditto) via a specific MQTT topic, e.g. containing the device/thing ID or name.
That would add an additional security mechanism, that a device A is prohibited from updating the thing of a device B.

For MQTT 3.1.1, the "input" can only have the value "{{ source:address }}" (for MQTT 5, also "{{ header:<header-name> }}" can be used) and the complete MQTT topic is then matched against the configured array of "filters".
The message is only accepted/processed if the MQTT topic matched the filter - which can make use of placeholders like {{ thing:id }} like documented.