Without a doubt, a killer feature of the HiveMQ MQTT broker is its built-in support for Websockets.


But first things first. HiveMQ is an MQTT broker written in Java, and as such it will probably run on anything with support for Java. After unpacking the distribution (all paths in here are relative to the directory in which I unpack it) I set the TCP port number for the broker to 1884, so that it wouldn’t collide with the Mosquitto server running on the same machine. Starting the broker is easy enough: bin/run.sh.


                  _    _  _              __  __   ____
                 | |  | |(_)            |  \/  | / __ \
                 | |__| | _ __   __ ___ | \  / || |  | |
                 |  __  || |\ \ / // _ \| |\/| || |  | |
                 | |  | || | \ V /|  __/| |  | || |__| |
                 |_|  |_||_|  \_/  \___||_|  |_| \___\_\


HiveMQ Start Script for Linux/Unix v1.1


Checking if Java is installed
Java was found. Starting HiveMQ....


No HIVEMQ_HOME is set, using default
Searching for HiveMQ in /Users/jpm/mqtt/hivemq/run/hivemq-1.4.1....
Starting HiveMQ...

2013-10-23 13:45:43,507 INFO  - HiveMQ home directory: /Users/jpm/mqtt/hivemq/run/hivemq-1.4.1
2013-10-23 13:45:43,510 INFO  - Starting HiveMQ Server
2013-10-23 13:45:45,367 WARN  - No license file found. Using free personal licensing with restrictions to 25 connections.
2013-10-23 13:45:45,557 INFO  - Activating statistics callbacks with an interval of 60 seconds
2013-10-23 13:45:45,557 INFO  - Activating $SYS topics with an interval of 60 seconds
2013-10-23 13:45:45,861 INFO  - Starting on all interfaces and port 1884
2013-10-23 13:45:45,868 INFO  - Starting with Websockets support on all interfaces and port 8000
2013-10-23 13:45:45,869 INFO  - Started HiveMQ 1.4.1 in 2363ms

After starting the broker, I published a few messages (using mosquitto_pub) and subscribed to the broker (using mosquitto_sub). I stopped the broker, edited the configuration file (conf/configuration.properties), and enabled Websocket support. In other words, the changes I’ve done so far are:


After restarting the broker, I used HiveMQ’s pretty cool MQTT Websocket Client to connect to localhost on port 8000. (Yes, localhost: the app is remote, but the [Paho] mqttws31.js JavaScript client it uses can connect to any Websocket server, also the one running on my local machine.) You can see the result in above screen shot. HiveMQ also have a very good post on building your own JavaScript MQTT Web app.

Under no circumstances is this to be considered a benchmark, but I fired off my little boom program, first to a Mosquitto and then to HiveMQ, both running on the same machine (on different TCP ports, of course). The results I got are impressive in both cases (both had a single subscriber listening to the messages):

M: Elapsed:  7.68. for 100000 queries ==  13024.42 qps
H: Elapsed: 10.19. for 100000 queries ==   9810.55 qps

HiveMQ has support for plugins – bits of code loaded into the broker at start-up. There are already a few plugins we can download and, if you’re a Java programmer you can develop your own plugins. I’m not such a person, so I simply tried installing the Accesslog plugin to see how that works.

The instructions seem easy enough:

  1. Place the access-log.jar in the plugins folder
  2. Done.

Almost. (The second point should be followed by a server restart, which ought to be obvious ;-)

2013-10-23 17:16:26,917 INFO  - Loaded Plugin Access Log Plugin - v1.1

Connections, subscription requests, publishes, etc. are logged into files in the log/ directory:

cat log/hivemq-access.131023.log
2013-10-23 17:16:27  mosqsub/84286-tiggr.ww. CONNECTED
2013-10-23 17:16:27  mosqsub/84286-tiggr.ww. SUBSCRIBED TO [Topic{topic='#', qoS=AT_MOST_ONCE}]
2013-10-23 17:16:49  mosqsub/87685-tiggr.ww. CONNECTED
2013-10-23 17:16:49  mosqsub/87685-tiggr.ww. SUBSCRIBED TO [Topic{topic='#', qoS=AT_MOST_ONCE}]
2013-10-23 17:16:53  br-tiggr-hivemq CONNECTED
2013-10-23 17:16:53  br-tiggr-hivemq SUBSCRIBED TO [Topic{topic='network/#', qoS=AT_MOST_ONCE}]
2013-10-23 17:16:57  mosqsub/87685-tiggr.ww. DISCONNECTED
2013-10-23 17:17:16  mosqsub/84286-tiggr.ww. DISCONNECTED
2013-10-23 17:17:20  mosqpub/87691-tiggr.ww. CONNECTED
2013-10-23 17:17:20  mosqpub/87691-tiggr.ww. PUBLISHED MESSAGE TO owner/name PAYLOAD: JP Mens
2013-10-23 17:17:20  mosqpub/87691-tiggr.ww. DISCONNECTED
2013-10-23 17:17:20  mosqpub/87691-tiggr.ww. DISCONNECTED

(The client called br-tiggr-hivemq is a bridge I configured from Mosquitto to HiveMQ; the latter doesn’t have support for configuring bridges.)

I’m impressed: everything I tried works.

HiveMQ has support for:

  • TLS (correctly named in the documentation, but the configuration parameters call it “ssl”)
  • X.509 client certificate authentication
  • the `$SYS/#’ topic branch (which can be disabled)
  • Websockets (as mentioned above) and secure Websockets
  • Authentication and authorization via plugins
  • Statistics-gathering
  • JMX
  • Graphite integration
  • Clustering
  • Plugins
  • Connection and bandwidth throttling

Clustering sounds particularly interesting, but I haven’t had a chance to test that yet. I also haven’t set up TLS for the simple reason I really don’t feel like wielding keytool at this time of the day, but I’m very certain that it’ll work as advertised.

The documentation for the HiveMQ broker is more than adequate (it’s rather good actually), and it’s really very easy to get started with the broker.

HiveMQ is not Open Source, but it’s free to use with a limited amount of simultaneous connections.