• Stars
    star
    438
  • Rank 99,453 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MQTT JMeter Plugin

mqtt-jmeter Overview

MQTT JMeter Plugin extends your JMeter's capability to test against MQTT protocol, just as easy as ordinary HTTP protocal.

It has been used to benchmark EMQ server performance, and here is the report link.

This plugin is developed and maintained by XMeter. XMeter is a professional performance testing service provider.

Install instruction

The plugin is a standard JMeter plugin. You can download the latest version of mqtt-jmeter from here, and then copy the downloaded JAR files into $JMETER_HOME/lib/ext folder. After restarting the JMeter, you can see "MQTT samplers" provided by this plugin.

To use this plugin, we recommend you to install JMeter 3.2 or above.

Build from source code

If you'd like to build binary by yourself, please clone the project and run 'mvn install'. Maven will download some JMeter dependency binary files, so the build elapsed time will up to your network status.

How to use

The plugin includes 4 samplers:

  • Connect sampler: Initiate MQTT server connection on behalf of a device. In addition to normal connection setup, this sampler can be used to simulate massive "background" connections(no data transimission but regular hearbeat signals) to the designated MQTT server or cluster system.

  • Pub sampler: publish various messages to the target MQTT server.

  • Sub sampler: subscribe message(s) from target MQTT server.

  • DisConnect sampler: Reset the connection to target MQTT server.

If MQTT JMeter plugin is successfully installed, you can find these MQTT samplers under JMeter 'Sampler' context menu.

mqtt_jmeter_plugin

Connect Sampler

conn_sampler

MQTT connection

This section includes basic connection settings.

  • Server name or IP: The MQTT target to be tested. It can be either IP address or server name. The default value is 127.0.0.1. DO NOT add protocol (e.g. tcp:// or ssl://) before server name or IP address!

  • Port number: The port opened by MQTT server. Typically 1883 is for TCP protocol, and 8883 for SSL protocol.

  • MQTT version: The MQTT version, default is 3.1, and another option is 3.1.1. Sometimes we found version 3.1.1 is required to establish connection to Azure IoTHub.

  • Timeout(s): The connection timeout seconds while connecting to MQTT server. The default is 10 seconds.

MQTT Protocol

The sampler supports 4 protocols, TCP, SSL, WS, WSS. For SSL and WSS protocols, it includes normal SSL and dual SSL authentication.

If 'Dual SSL authentication' is checked, please follow 'Certification files for SSL/TLS connections' at end of this doc to set the client SSL configuration properly.

protocol_setting

User authentication

User can configure MQTT server with user name & password authentication, refer to EMQ user name and password authentication guide.

  • User name: If MQTT server is configured with user name, then specify user name here.

  • Password: If MQTT server is configured with password, then specify password here.

Connection options

  • ClientId: Identification of the client, i.e. virtual user or JMeter thread. Default value is 'conn_'. If 'Add random client id suffix' is selected, JMeter plugin will append generated uuid as suffix to represent the client, otherwise, the text of 'ClientId' will be passed as 'clientId' of current connection.
  • Keep alive(s): Ping packet send interval in seconds. Default value is 300, which means each connection sends a ping packet to MQTT server every 5 minutes.
  • Connect attampt max: The maximum number of reconnect attempts before an error is reported back to the client on the first attempt by the client to connect to a server. Set to -1 to use unlimited attempts. Defaults to 0.
  • Reconnect attampt max: The maximum number of reconnect attempts before an error is reported back to the client after a server connection had previously been established. Set to -1 to use unlimited attempts. Defaults to 0.
  • Clean session: If you want to maintain state information between sessions, set it to false; otherwise, set it to true.

Pub Sampler

pub_sampler

Pub sampler reuses previously established connection (by Connect sampler) to publish a message. If connection is not ready at this moment, pub sampler will just fail immediately.

Pub options

  • QoS level: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.
  • Retained messages: Set it to true if the Pub sampler wants the broker to keep the last message on the given topic, so that the client subscribed to that topic receives the retained message immediately after subscription.
  • Topic name: Name of the topic that the message will be sent to.
  • Add timestamp in payload: Add timestamp in the payload or not. If the checkbox is enabled, then timestamp of running pub sampler will be added before real payload. Mostly it's used together with Sub sampler to calculate message latency time.

Payloads

Message type: 3 types of message can be used.

  • String: The normal string that sent to MQTT server. It can also be a JMeter variable.

  • Hex string: The hex string that sent to MQTT server. The chars input must be [0-9] or [A-F] or [a-f]. The hex string will be converted to binary and send to server. It can also be a JMeter variable.

  • Random string with fixed length: Refer to below screenshot. If the option is selected, then it requires user to input 'Length'. The length means the auto generated string length. Default is 1024, which means generated a 1kb size of random string.

payload_setting

Sub Sampler

sub_sampler

Sub sampler reuses previously established connection (by Connect sampler) to subscribe message(s). If connection is not ready at this moment, sub sampler will just fail immediately.

Sub options

  • QoS level: The available QoS value, 0 is AT_MOST_ONCE, 1 is AT_LEAST_ONCE and 2 is EXACTLY_ONCE.

  • Topic name(s): A list of topic names (comma-separated) that will be subscribed to.

  • Payload includes timestamp: If the checkbox is enabled, then it means the payload includes timestamp. It can be used to calcuate the message latency time.

message_latency = timestamp_in_sub_when_receive_msg - timestamp_in_payload (timestamp in pub machine when sending out message)

Please notice, if the machine publish message is not the same as subscriber, then the calculated message latency time is not accurate. 
It's because the time is almost not the same in different machines. So the latency time calculated by sub sampler could be only be a reference.
  • Sample on: It controls how to sample. The default value is 'elapsed with specified time(ms)', which means a sub sampler will occur every specified milli-seconds (default is 1000ms). During the 1000 ms, multiple messages could be received, and result in report is the summarized data during 1000 ms. If the value is set to 2000, then means summarized report during 2000 ms. Another option is 'number of received messages', which means a sub sampler will occur after receiving these specified number of messages (default is 1).

  • Debug response: If checked, the received message will be print in response. It's recommended to enable this option when you debug your script.

DisConnect Sampler

disconn_sampler

This sampler is very simple, it just clear the previous created connection. Therefore, next time you run Connect sampler, it will initiate a new MQTT server connection for you. As you can imagine, Disconnect sample will fail immediately if no connection is detected at this moment.

Example JMeter Scripts

As a reference, you can check out some example scripts in SampleScripts folder.

  1. background_connection.jmx: Simulate massive background MQTT connections to server. You can optionally subscribe to a topic when connecting. (Please modify "xmeter_runtime_vars" UDV to fit your needs.)

  2. pubsub_unidirection.jmx: Demonstrate how sub sampler can get messages from corresponding pub sampler, with two JMeter user groups and delay between opertions.

  3. pubsub_bidirection.jmx: Demonstrate how a set of Devices and Mobiles exchange messages in both directions.

example_scripts

Certification files for SSL/TLS connections

After deploying emqtt server, you get the following OOTB (out of the box) SSL/TLS certification files under ${EMQTTD_HOME}/etc/certs directory:

  1. cacert.pem : the self-signed CA certification

  2. cert.pem : certification for emqtt server

  3. client-cert.pem : certfication for emqtt client in order to connect to server via SSL/TLS connection. In this jmeter plugin case, the client implies jmeter "virtual user"

  4. client-key.pem key.pem : key files to protect client and server certification respectively

[Note:] The above server and client certifications are both issued by the self-signed CA. If you would like to use official certifications for your EMQTT deployment, please check out relevant document to configure it.

We will use the OOTB test certfications (as an example) to show you how to prepare the required certification files for this EMQTT JMeter plugin.

export PATH=$PATH:<YOUR_JDK_HOME>/bin

keytool -import -alias cacert -keystore emqtt.jks -file cacert.pem -storepass <YOUR_PASSWORD> -trustcacerts -noprompt
keytool -import -alias client -keystore emqtt.jks -file client-cert.pem -storepass <YOUR_PASSWORD>
keytool -import -alias server -keystore emqtt.jks -file cert.pem -storepass <YOUR_PASSWORD>

openssl pkcs12 -export -inkey client-key.pem -in client-cert.pem -out client.p12 -password pass:<YOUR_PASSWORD>

Specify key store, client certfication and corresponding pass phrases in plugin sampler:

ssl_conn

More Repositories

1

emqx

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles
Erlang
13,975
star
2

MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.
TypeScript
3,843
star
3

CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
Swift
1,589
star
4

neuron

Open source industrial IoT connectivity server
C
1,023
star
5

MQTT-Client-Examples

MQTT Client Examples
Kotlin
743
star
6

qmqtt

MQTT client for Qt
C++
693
star
7

emqtt-bench

Lightweight MQTT benchmark tool written in Erlang
Erlang
511
star
8

emqtt

Erlang MQTT 5.0 Client
Erlang
365
star
9

quic

QUIC protocol for Erlang & Elixir
Erlang
220
star
10

emqx-operator

A Kubernetes Operator for EMQX
Go
209
star
11

esockd

Erlang general non-blocking TCP/SSL socket server
Erlang
199
star
12

emqx-rel

Release Project for EMQX Broker prior to 4.3. Newer releases are built here: https://github.com/emqx/emqx
Shell
189
star
13

emqx-docs

EMQX product documentation
HTML
156
star
14

NanoSDK

NanoSDK - MQTT 5.0-compliant SDK with QUIC support in NNG flavor
C
126
star
15

mria

Asynchronously replicated Mnesia-like database for Erlang/Elixir
Erlang
117
star
16

qmqtt-client

MQTT Client GUI Written with Qt
C++
97
star
17

ekka

Autocluster and Autoheal for EMQX Broker
Erlang
94
star
18

emqx-web-hook

EMQX Webhook Plugin
Erlang
79
star
19

emqx-rule-engine

EMQX Rule Engine
Erlang
69
star
20

emqx-plugin-template

EMQ X Plugin Template and Demo
Erlang
63
star
21

emqx-coap

EMQX CoAP Gateway
Erlang
61
star
22

emqx-auth-mysql

Authentication, ACL with MySQL Database
Erlang
55
star
23

emqx-dashboard

EMQ X Dashboard
CSS
52
star
24

MQTT-Web-Toolkit

EMQ Web Toolkit
Vue
44
star
25

emqx-extension-examples

Examples for ExHook & ExProto
Erlang
44
star
26

emqx-auth-http

EMQX HTTP Authentication/ACL Plugin
Erlang
43
star
27

emqx-dashboard5

The management console used to monitor and manage EMQX clusters.
Vue
42
star
28

neuron-dashboard

Neuron Dashboard
TypeScript
41
star
29

minirest

A Mini RESTful API Framework
Erlang
37
star
30

emqx-bridge-mqtt

Bridge of MQTT (deprecated since EMQX v5)
Erlang
37
star
31

replayq

Generic on-disk persistent queue implementation for Erlang
Erlang
35
star
32

emqx-auth-pgsql

EMQ X PostgreSQL Authentication Plugin
Erlang
35
star
33

edge-stack

Shell
34
star
34

emqx-auth-redis

EMQ X Redis Authentication/ACL Plugin
Erlang
33
star
35

hocon

HOCON configuration Parser for Erlang/OTP
Erlang
32
star
36

mqttbs

MQTT Benchmark Suite
32
star
37

mqtt5.0-cn

MQTT Version 5.0 Chinese
31
star
38

emqx-docker

An Open-Source, Cloud-Native, Distributed MQTT Message Broker for IoT.
Shell
30
star
39

emqx-lwm2m

EMQ X LwM2M Gateway
Erlang
30
star
40

emqx-sn

EMQX MQTT-SN Gateway
Erlang
29
star
41

emqx-auth-jwt

EMQ X JWT Authentication Plugin
Erlang
28
star
42

emqx-lua-hook

EMQ X Lua Hook
Erlang
28
star
43

ecpool

Erlang Connection/Client Pool Library
Erlang
28
star
44

emqx-exporter

Prometheus exporter for EMQX
Python
26
star
45

emqx-dashboard-frontend

EMQ X Dashboard Frontend
Vue
25
star
46

emqx-prometheus

EMQX Statsd
Erlang
24
star
47

emqx-exhook

The Multiple-Language extension plugin for EMQ X Hooks
Erlang
23
star
48

blog

EMQ Blog
Python
22
star
49

emqx-retainer

EMQ X Retainer
Erlang
21
star
50

emqx-auth-mongo

EMQ X Authentication/ACL with MongoDB
Erlang
21
star
51

coap-jmeter

CoAP JMeter Plugin
Java
20
star
52

eip

EMQX Improvement Proposals
Makefile
19
star
53

emqx-elixir-plugin

An Example Plugin for EMQX in Elixir
Elixir
19
star
54

emqx-exproto

The Multiple-Language extension plugin for Protocol access
Erlang
18
star
55

openai-mqtt-nodejs

Node.js project that combines OpenAI's API with MQTT for real-time AI-driven interactions in IoT ecosystems.
JavaScript
18
star
56

emqx-auth-username

EMQ X Authentication with Username and Password
Erlang
17
star
57

mqtt-to-timescaledb

Ingesting time series data into TimescaleDB using MQTT and EMQX | MQTT Timescale Integration
Makefile
16
star
58

erlang-rocksdb

Upstream is here: https://gitlab.com/barrel-db/erlang-rocksdb
C++
16
star
59

emqx-auth-clientid

EMQ X ClientId Authentication Plugin
Erlang
16
star
60

jq

jq (nif) for beam
C
15
star
61

emqx-dashboard-web

Frontend Source Code for EMQ X dashboard Enterprise v4
Vue
15
star
62

emqx-tutorial-cn

EMQ X ไธญๆ–‡Tutorial
14
star
63

emqx-extension-java-sdk

The Java SDK for emqx-extension-hook
Java
14
star
64

emqttb

A scriptable autotuning load generator for MQTT
Erlang
14
star
65

neuron-docs

Neuron Documentation
Shell
14
star
66

emqx-extension-python-sdk

The Python SDK for emqx-extension-hook
Python
13
star
67

HBridge

High-performance MQTT Bridge written in Haskell
Haskell
12
star
68

cdk-emqx-cluster

Python
11
star
69

pulsar-client-erl

Apache Pulsar client for Erlang/Elixir
Erlang
11
star
70

emqx-management

EMQ X Management API
Erlang
10
star
71

wormhole

The channel for routing request from cloud to edge.
Go
10
star
72

local-storage-encryption

Obfuscate key-value pairs in localStorage.
JavaScript
10
star
73

deploy-emqx-to-aws-with-terraform

HCL
10
star
74

mqtt-to-kafka

Streaming IoT data into Confluent/Kafka using MQTT and EMQX | MQTT Kafka Integration
Makefile
10
star
75

emqx-ui

EMQX UI Library
Vue
9
star
76

cloud-docs

EMQX Cloud Documentations
CSS
9
star
77

emqx-meter-cn

EMQ X Meter Benchmark
Python
9
star
78

emqx-usage-example

Using Docker Compose to show different usages of EMQX
9
star
79

mqtt-to-influxdb

Ingesting time series data into InfluxDB using MQTT and EMQX | MQTT InfluxDB Integration
JavaScript
8
star
80

example

EMQ x IoT project sample code
Java
8
star
81

ehttpc

HTTP Client for Erlang/OTP
Erlang
7
star
82

mqtt-security-scanner

MQTT Security Scanner
Go
7
star
83

rebar3_emqx_plugin

A rebar3 plugin for automatically generate emqx plugin template
Erlang
7
star
84

ipqueue

High Performance Interleaved Priority Queue for Erlang/Elixir
Erlang
7
star
85

ecql

Erlang Cassandra CQL Driver
Erlang
7
star
86

deploy-emqx-to-alibabacloud-with-terraform

HCL
6
star
87

influxdb-client-erl

Erlang
6
star
88

lc

Load Control for beam
Erlang
6
star
89

emqx-recon

Recon debug/optimize plugin
Erlang
6
star
90

tf-emqx-performance-test

HCL
6
star
91

emqx-builder

Dockerfile
5
star
92

emqx-reloader

Erlang Module Reloader
Erlang
5
star
93

emqx-exproto-java-sdk

The Java SDK for emqx-exproto
Java
5
star
94

emqx-stomp

EMQ X Stomp Protocol Plugin
Erlang
5
star
95

emqx-webinars

Webinar materials
Shell
5
star
96

bootcamp

The learning center of EMQ products
C
5
star
97

mqtt-to-redis

Ingesting IoT data into Redis using MQTT and EMQX | MQTT Redis Integration
JavaScript
5
star
98

emqx-auth-ldap

EMQ X LDAP Authentication Plugin
Erlang
5
star
99

nanomq-docker

An ultra-lightweight and blazing-fast MQTT broker for IoT edge
Dockerfile
4
star
100

emqx-10million-test-cn

EMQ X 10MILLION TEST
4
star