Search code examples
eclipse-hono

Hono command and control API not receiving messages


I'm trying to subscribe to the control topic. The mqtt adapter shows following logging when I subscribe:

14:28:47.933 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - created subscription [tenant: tenant_aloxy, device: device-aloxy, filter: control/tenant_aloxy/device-aloxy/req/#, requested QoS: AT_MOST_ONCE, granted QoS: AT_MOST_ONCE]

When I publish messages to control/tenant_aloxy/device-aloxy/req//alp the device is not getting the message and I'm not getting any error logging in the hono mqtt adapter. However, when I subscribe to the topic myself using following command: qb message receive control/tenant_aloxy/device-aloxy/req/# -b amqp://user:secret@hostname:5672, I'm getting the messages. Any idea where to look?

The Hono version I'm currently using is from commit https://github.com/eclipse/hono/commit/78979346212446dc6cf8b8b3255f048e19e81210

UPDATE
I updated Hono to version 0.9-M2 and still have the same problem. The logging when subscribing is the following:

12:21:02.407 [vert.x-eventloop-thread-0] INFO  o.e.h.s.m.LoggingConnectionEventProducer -    Connected - ID: device_interface_client_b24704c9-ed11-41af-a0e0-ba90264a7362, Protocol Adapter: hono-mqtt, Device: device [device-id: device-aloxy, tenant-id: tenant_aloxy], Data: null
12:21:02.515 [vert.x-eventloop-thread-0] DEBUG o.e.h.client.impl.AbstractHonoClient - receiver open [source: control/tenant_aloxy/device-aloxy]
12:21:02.515 [vert.x-eventloop-thread-0] DEBUG o.e.hono.client.CommandConsumer - successfully created command consumer [control/tenant_aloxy/device-aloxy]
12:21:02.517 [vert.x-eventloop-thread-0] DEBUG o.e.h.a.m.i.VertxBasedMqttProtocolAdapter - created subscription [tenant: tenant_aloxy, device: device-aloxy, filter: control/+/+/req/#, requested QoS: AT_MOST_ONCE, granted QoS: AT_MOST_ONCE]

I publish my messages to queue control/tenant_aloxy/device-aloxy/req//alp

UPDATE 2
I discovered something strange. Following screenshot shows the metrics from an enmasse perspective: Enmasse view on connection

It shows that several messages have been published to the queue but have been rejected by the Hono MQTT Adapter. However, I do not see any logging for these messages in the console although SPRINT_PROFILE "dev" is activated.


Solution

  • I think that you are publishing to the wrong address. Please also keep in mind that the applications sending commands are not publishing to a topic (that's MQTT parlais) but instead send an AMQP message to a remote node which is identified by an address.

    That said, your application should send the command over a sender link with a target address of control/tenant_aloxy/device-aloxy (see Preconditions of https://www.eclipse.org/hono/api/command-and-control-api/#send-a-one-way-command). Note that the target address is different from the MQTT topic name that the device subscribes to.

    If you are expecting a response then you also need to open a receiver link and include the receiver link's source address as the value of the reply-to property in the command message (as described in https://www.eclipse.org/hono/api/command-and-control-api/#send-a-request-response-command).