When Christoph and I met for a pretty decent Indian meal a few months ago, the idea for a general MQTT viewer on iOS was born, but because progress on MQTTitude was more important, nothing really came of that until I saw a tweet by Andy Piper: I sent Christoph a friendly reminder, and he’s been working on the MQTT Inspector since.

logo

The idea is to have a monitor app with which you can connect to an MQTT broker, subscribe to a number of topics and publish a text payload to a topic or two for debugging purposes.

The result is a pretty versatile utility for your MQTT toolchest. It serves as a viewer with which you can observe payloads being published to topics you’re interested in, and you can publish payloads to topics at the tap of a button. The app is designed to work on both iPad and iPhone (the screenshot at the bottom shows the Inspector on an iPhone).

main panel

MQTT-Inspector provides two pre-defined sessions to public test brokers, but you can remove those if you don’t need them, and you can add your own connections. Support for TLS and authentication are there and support for DNS SRV records is in the making. (I recently also submitted a patch to PAHO’s/Mosquitto’s Python client for the same.)

In each session you can pre-define subscriptions and publications (with pre-defined payloads) to particular MQTT topics.

pre-configured SUBscriptions

Clicking on a session connects to the MQTT broker host I configured for that session, or to a host obtained via DNS SRV. Then, on the left side of the screen, I tap on the subscription(s) I want to activate. That’s when the action begins:

topic-panel-active-subs

There are three main panels:

  • the Topics panel shows incoming messages on a per/topic basis. New messages for the same topic overwrite the previous. I particularly wanted this mode so as to be able to easily monitor values which change, e.g. a temperature sensor, etc.
  • The Messages panel shows incoming messages as they arrive, inserting the newest at the top.
  • The Low Level panel shows debugging information and the raw MQTT commands being exchanged with the connected broker. (At the top of this panel you can also see the connection URL.)

Each message on the Topics panel looks like this:

a message

  • The first line contains a portion of the payload in clear text (if printable) or in hex.
  • The second line holds:
    1. A timestamp when the message was received
    2. The topic branch at which the message was received (in bold)
    3. The size of the payload in (octets)
    4. A counter indicating how many messages have arrived on this particular topic (#n)

Tapping the (I) shows the full payload in a fixed-width font, and I can select and copy that:

full payload

There are three notable UI elements on the bottom right, and I’ll start with the easier ones, from right to left:

PUBlish

  • Tapping Clear (Trash on iPhone) simply clears the current pane (i.e. all received messages disappear from the screen).
  • Sliding the switch “freezes” the current pane: no more messages are displayed, although the app continues receiving them; it will display them as soon as you “unfreeze” it.
  • Tapping PUB will open the dialog shown above to create an “ad-hoc” publish. This is different to a saved publish (associated with a session) in that it doesn’t have to be preconfigured. As with saved PUBs, the tokens %t and %c are replaced with a UNIX timestamp and the MQTT client-ID respectively. This ad-hoc PUB is saved, and you can publish its value by tapping <last> on the list of PUBs. To configure PUBs in general, access them via the Sessions menu:

preconfigured PUB

MQTT Inspector shows a blue bar at the bottom of the screen, a bit like a spring which contracts and expands. That indicator shows whether all incoming messages have been processed; watch it move when you’re subscribed to topics with a lot of traffic on them (e.g. a subscription to #) and during an explcit “freeze”.

The Inspector runs on iPhone as well, but due to the available screen real-estate, the experience is slightly different. For example, to see the fully expanded list of pre-configured SUBs, you’d long-hold on the list of SUBs.

on iPhone

Christoph has produced a short introductory video to Inspector and his repository on Github has the source code of MQTT Inspector. The app is now available on the App store.

** Update: 2012-02-04 **

Version 1.3 brings new features:

  • Export, edit, import session settings via e-mail / JSON
  • Filtering of incoming messages using regular expressions on topics and payload