Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Ditto » Receiving responses from Ditto twin commans over Hono MQTT adapter
Receiving responses from Ditto twin commans over Hono MQTT adapter [message #1847124] Fri, 15 October 2021 10:37 Go to next message
Vit Holasek is currently offline Vit HolasekFriend
Messages: 2
Registered: October 2021
Junior Member
Hello.
I'm trying to integrate my device to Hono/Ditto stack (deployed by Cloud2Edge package helm chart) using MQTT protocol over Hono. I'm able to connect and sending twin modification commands and receiving event works good. But I'm not able to setup my client to receive command responses (e.g. for modify or especially retrieve command).

I'm sending RetrieveFeature command on telemetry channel with QoS 1:
{
   "topic":"org.eclipse.packages.c2e/demo-device/things/twin/commands/retrieve",
   "headers":{
      "correlation-id":"f579404f-be7c-4799-80dc-4a7892c24fa3",
      "ditto-message-direction":"FROM",
      "response-required":"true"
   },
   "path":"/features/temperature"
}


I'm also subscribed to Hono command topic correctly. Policies are set and modify command on the same feature works. In Ditto logs the command seems to be processed but RetrieveFeatureResponse is never delivered to the device. The same for modify command.

Replies on Ditto/Hono connection are set in default way:
"sources":[
           {
              "addresses":[
                 "telemetry/org.eclipse.packages.c2e",
                 "event/org.eclipse.packages.c2e"
              ],
              "consumerCount":1,
              "authorizationContext":[
                 "pre-authenticated:hono-connection"
              ],
              "enforcement":{
                 "input":"{{ header:device_id }}",
                 "filters":[
                    "{{ entity:id }}"
                 ]
              },
              "acknowledgementRequests":{
                 "includes":[
                    
                 ],
                 "filter":"fn:filter(header:qos,'eq','1')"
              },
              "headerMapping":{
                 "hono-device-id":"{{ header:device_id }}",
                 "content-type":"{{ header:content-type }}"
              },
              "replyTarget":{
                 "address":"{{ header:reply-to }}",
                 "headerMapping":{
                    "content-type":"{{ header:content-type | fn:default('application/vnd.eclipse.ditto+json') }}",
                    "to":"command/org.eclipse.packages.c2e/{{ header:hono-device-id }}",
                    "subject":"{{ header:subject | fn:default(topic:action-subject) | fn:default(topic:criterion) }}-response",
                    "correlation-id":"{{ header:correlation-id }}"
                 },
                 "expectedResponseTypes":[
                    "response",
                    "error"
                 ],
                 "enabled":true
              }
           },
           {
              "addresses":[
                 "command_response/org.eclipse.packages.c2e/replies"
              ],
              "consumerCount":1,
              "authorizationContext":[
                 "pre-authenticated:hono-connection"
              ],
              "headerMapping":{
                 "content-type":"{{ header:content-type }}",
                 "correlation-id":"{{ header:correlation-id }}",
                 "status":"{{ header:status }}"
              },
              "replyTarget":{
                 "enabled":false
              }
           }
        ]


Can someone give me please advice what am I doing wrong or what else should be configured?
Re: Receiving responses from Ditto twin commans over Hono MQTT adapter [message #1847155 is a reply to message #1847124] Sat, 16 October 2021 12:06 Go to previous messageGo to next message
Thomas Jaeckle is currently offline Thomas JaeckleFriend
Messages: 7
Registered: August 2018
Junior Member
Hi.

The default configuration for replies is:

"replyTarget":{
"address":"{{ header:reply-to }}",

That means you have either to provide a field "reply-to" in the "headers" of your Ditto Protocol json message with an address Hono uses for sending commands.

Or you can also statically add that to the connections configuration instead of using the placeholder in the "address" value.
This however will cause that for all telemetry messages eg updating a thing a response will be sent back, unless the "responseRequired" header was explicitly set to false.
Re: Receiving responses from Ditto twin commans over Hono MQTT adapter [message #1847180 is a reply to message #1847155] Mon, 18 October 2021 12:01 Go to previous message
Vit Holasek is currently offline Vit HolasekFriend
Messages: 2
Registered: October 2021
Junior Member
Hi Thomas,
thank you, now I understand it. Using the address "command/org.eclipse.packages.c2e" as reply-to now works as expected.
Previous Topic:Integration of Matlab Models in Eclipse Ditto Digital Twins
Next Topic:[Ditto java client] how to convert java dto object to JsonValue
Goto Forum:
  


Current Time: Sun Dec 04 12:05:16 GMT 2022

Powered by FUDForum. Page generated in 0.02118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top