Over on Stack Overflow there is a question about implementing request/response interaction over MQTT. As one answer notes, you can do it by publishing the request on one topic and listening for the response on another token that was included in the request. It's a little awkward, but it works.

As MQTT is used extensively throughout IoT, I wonder, have there been any attempts to standardize this RPC type interaction for the sake of interoperability?


3 Answers 3


I am unaware of any such standards.

As pointed out in the answers to the other question, pub/sub doesn't lend itself to RPC but it can be bent to fit.

One of MQTT's strengths is that the payload can be anything at all, allowing a developer to make the best choice for their project.


I am not sure what is your requirement for standardized RPC communication method over MQTT but I still made a little search around and found several points to deliver to you.

First of all, about the standard method. On one Github rpc project the description kind of nails it:

This module provides an rpc interface for an mqtt connection, in essence this is a request and response strategy which uses an MQTT topic structure as transport.

The point is to use stack model (OSI model is a standard) and just use MQTT as one of the stack's layers.

This project on json-rpc over mqtt uses standardized or at least well known protocol over MQTT.

About awkwardness, you do not have to build the MQTT and the RPC on top of it from scratch but instead use one of the linked libraries or some other found on Github.

OK, for every language there is no ready basis on Github, but in that case the compliance becomes a planning criteria and may affect the whole other project, unfortunately.

  • I've no real requirement. The impetus for the question is comparing CoAP (which has RFC defined request/response and pub/sub mechanisms) to MQTT which I'm reasonably sure now only has standardised pub/sub. Certainly having some open source libraries for RPC is better than nothing. Commented Sep 19, 2017 at 18:48

Azure IoT Hub has a concept of direct methods:

IoT Hub gives you ability to invoke direct methods on devices from the cloud.

This is implemented over MQTT (AMQP is not supported), where

Devices receive direct method requests on the MQTT topic:

$iothub/methods/POST/{method name}/?$rid={request id}.

They've wrapped this in their SDK, so developers don't need to worry about specifically monitoring the topic. You could implement a similar approach.

As per other answers, pub-sub does not lend itself to RPC, and there are not any standards, as far as I'm aware.

More documentation is here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.