Closed rinelb closed 1 year ago
When you use a single connection for source
and target
, updates to twins which were caused by the source
of the connection will not be published to the target
- as Ditto makes the assumption that the source already knows of the change of device state.
If you need to be informed, you would need to create a second MQTT connection with the target - and the first one would only contain the connection source
.
Edit: However, be very careful if you use the same addresses you already have in your config - as your source consumes from MQTT address "ditto-tutorial/#"
and you publish to "address": "ditto-tutorial/{{ thing:id }}"
, the source will consume MQTT messages from your target which could cause a loop.
Hi @thjaeckle thanks for quick reply and explanation, much appreciated opening a second connection as a target worked for me
the scenario we need is, devices are sending data to ditto via MQTT with topic "ditto-tutorial/{{ thing:id }}" using "mqtt Broker1". When ditto recieves data from the device, it send out the data to a seperate MQTT broker "MQTT Broker2" with a topic for example "ditto/data/live/{{ thing:id }}" and there is a master device that subscribes from MQTT Broker2 with topic "ditto/data/+"
For now we just want to get it working on one broker.
if anyone interested this is the second connection templet that worked for me
{
"id": "mqtt-example-connection-321",
"name": null,
"connectionType": "mqtt",
"connectionStatus": "open",
"uri": "tcp://test.mosquitto.org:1883",
"sources": [],
"targets": [
{
"address": "ditto/data/{{ thing:id }}",
"topics": [
"_/_/things/twin/events",
"_/_/things/live/messages"
],
"qos": 0,
"authorizationContext": [
"nginx:ditto"
],
"headerMapping": {}
}
],
"clientCount": 1,
"failoverEnabled": true,
"validateCertificates": true,
"processorPoolSize": 1,
"tags": []
}
I am not receiving updates via MQTT from ditto, How do i setup the ditto connection to send MQTT messages when a thing is updated
i can send data to ditto via MQTT and the features of the thing gets updated I followed the example show on https://github.com/eclipse-ditto/ditto-examples/blob/master/mqtt-bidirectional/README.md
im running eclipse ditto on docker on windows 10 i ran docker compose from the ditto/deployment/docker folder
it create a think called "my.test:octopus" and send data via MQTT to update the features from the tutorial above
here is my CRUD Connection Template
im using python script to send data via MQTT to update the my.test:octopus device
I can see on the UI that ditto is updating the my.test:octopus when ever it recieves mqtt messages show above
i am running a seperate python script that is subscribing to the following topics
it recieves topic1 only, this is just to make sure the subscribe is working
note for topic "test/ditto/data" i added
to the "replyTarget" and "targets" tags and both on the templet above but that didnt work so i removed it.
then i went back to the same templet above and caputred the logs below shows the logs of the "eclipse/ditto-connectivity:lates"