mqttios-mqtt-client-framework

Can MQTT-SN v1.2 support the request-response pattern that is supported by MQTT v5?


I read the MQTT-SN spec and I am unsure if it also can support the request-response pattern. Does anyone know ?

Trying to implement something like this... http://www.steves-internet-guide.com/mqttv5-request-response/

Where the MQTT v5 publish command can specify the response-topic as seen in the MQTT v5 spec here: https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html

4.10.1 Basic Request Response (non-normative) Request/Response interaction proceeds as follows:

  1. An MQTT Client (the Requester) publishes a Request Message to a topic. A Request Message is an >Application Message with a Response Topic.

  2. Another MQTT Client (the Responder) has subscribed to a Topic Filter which matches the Topic Name >used when the Request Message was published. As a result, it receives the Request Message. There could >be multiple Responders subscribed to this Topic Name or there could be none.

  3. The Responder takes the appropriate action based on the Request Message, and then publishes a >Response Message to the Topic Name in the Response Topic property that was carried in the Request >Message.

  4. In typical usage the Requester has subscribed to the Response Topic and thereby receives the >Response Message. However, some other Client might be subscribed to the Response Topic in which case the >Response Message will also be received and processed by that Client. As with the Request Message, the >topic on which the Response Message is sent could be subscribed to by multiple Clients, or by none.

The MQTT-SN spec is here http://mqtt.org/new/wp-content/uploads/2009/06/MQTT-SN_spec_v1.2.pdf

It is just written differently and I cannot tell if this feature is supported.

Ultimately, for certain messages, I need to have a response which cannot be left to the pub/sub fire and forget pattern. MQTT-SN v1.2 is required for the connection since it goes over BLE and cannot support TCP/IP and so no regular MQTT v5.

I suppose I could just make up a "Response Topic" field to put into the payload of the request which the receiving client can process and respond to. But, does the MQTT-SN v1.2 spec already support it ?


Solution

  • No, MQTT-SN v1.2 does not include the features added to MQTT in v5.

    As you said, there is nothing to stop you including your own response topic field in the message payload.