BreakingExpress

How to make use of the open supply MQTT plug-in in JMeter

In a previous article, I described how JMeter has built-in help for HTTP, HTTPS, TCP, and different widespread protocols and has a plug-in extension mechanism.

Through plug-ins, you’ll be able to help far more than simply what’s built-in, together with MQTT.

MQTT is a mainstream protocol within the IoT world. Although it isn’t a protocol sort that comes with JMeter, this can be very widespread in IoT testing situations. In order to help the load testing of the MQTT protocol, EMQ developed a JMeter-based open supply testing plug-in for the MQTT protocol.

This article introduces the best way to use the MQTT plug-in in JMeter.

Install the MQTT plug-in on JMeter

The set up of the MQTT plug-in is much like different JMeter third-party plug-ins:

  1. Download the newest model of the plug-in mqtt-xmeter-2.0.2-jar-with-dependencies.jar from GitHub. The plug-in helps JMeter 3.2 and above.
  2. Copy the plug-in jar bundle to the plug-in listing of JMeter: $JMETER_HOME/lib/ext.
  3. Restart JMeter.

At the time of writing, the JMeter MQTT plug-in helps quite a lot of samplers, corresponding to connection, message publish, and message subscription.

These could be mixed to construct extra advanced check situations.

MQTT join sampler

The Connect Sampler simulates an IoT gadget and initiates an MQTT connection.

(Chongyuan Yin, CC BY-SA 4.0)

Server identify or IP: The tackle of the MQTT server being examined.

Port quantity: Taking the EMQX Broker for instance, the default ports are 1883 for TCP connections and 8883 for SSL connections. Please consult with the particular configuration of the server for the particular port.

MQTT model: Presently helps MQTT 3.1 and three.1.1 variations.

Timeout: Connection timeout setting, in seconds.

Protocols: Supports TCP, SSL, WS, and WSS connections to MQTT servers. When deciding on an SSL or WSS encrypted channel connection, a one-way or two-way authentication (Dual) could be chosen. If two-way authentication is required, specify the suitable consumer certificates (p12 certificates) and the corresponding file safety password (Secret).

User authentication: If the MQTT server is configured for person authentication, present the corresponding Username and Password.

ClientId: The identification of the digital person. If Add random suffix for ClientId is enabled, a UUID string is added as a suffix to every ClientId and the entire digital person identifier.

Keep alive: The interval for sending heartbeat alerts. For instance, 300 implies that the consumer sends ping requests to the server each 300 seconds to maintain the connection lively.

Connect try max: The most variety of reconnection makes an attempt through the first connection. If this quantity is exceeded, the connection is taken into account failed. If the person needs to maintain making an attempt to reconnect, set this to -1.

Reconnect try max: The most variety of reconnect makes an attempt throughout subsequent connections. If this quantity is exceeded, the connection is taken into account failed. If the person needs to maintain making an attempt to reconnect, set this to -1.

Clean session: Set this selection to false when the person needs to maintain the session state between connections or true when the person doesn’t wish to hold the session state in new connections.

MQTT message publish sampler (MQTT Pub Sampler)

The message publish sampler reuses the MQTT connection established within the Connection Sampler to publish messages to the goal MQTT server.

(Chongyuan Yin, CC BY-SA 4.0)

QoS Level: Quality of Service, with values 0, 1, and a couple of, representing AT_MOST_ONCE, AT_LEAST_ONCE, and EXACTLY_ONCE, respectively, within the MQTT protocol specification.

Retained messages: If you wish to use retained messages, set this selection to true to have the MQTT server retailer the retained messages printed by the plug-in utilizing the given QoS. When the subscription happens on the corresponding subject, the final retained message is delivered on to the subscriber. Therefore, the subscriber doesn’t have to attend to get the newest standing worth of the writer.

Topic identify: The subject of the printed message.

Add timestamp in payload: If enabled, the present timestamp is connected to the start of the printed message physique. Together with the Payload consists of timestamp choice of the message subscription sampler, this may calculate the delay time reached by the message on the message receiving finish. If disabled, solely the precise message physique is shipped.

Payloads and Message sort: Three message sorts are presently supported:

  • String: Ordinary string.
  • Hex String: A string is offered as a hexadecimal worth, corresponding to Hello, which could be represented as 48656C6C6F (the place 48 corresponds to the letter H within the ASCII desk, and so forth). Typically, hexadecimal strings are used to assemble non-textual message our bodies, corresponding to describing sure non-public protocol interactions, management info, and so forth.
  • Random string with a hard and fast size: A random string of a specified size (in bytes) is generated as a message physique.

MQTT message subscription sampler (MQTT Sub Sampler)

The Message Pub Sampler reuses the MQTT connection established within the Connection Sampler to subscribe to messages from the goal MQTT server.

(Chongyuan Yin, CC BY-SA 4.0)

QoS Level: Quality of Service, the that means is identical as that for the Message Pub Sampler.

Topic identify: The subject to which the subscribed message belongs. A single message subscription sampler can subscribe to a number of subjects, separated by commas.

Payload consists of timestamp: If enabled, the timestamp is parsed from the start of the message physique, which can be utilized to calculate the obtain delay of the message with the Add timestamp within the payload choice of the message supply sampler. If disabled, solely the precise message physique is parsed.

Sample on: For the sampling methodology, the default is specified elapsed time (ms), corresponding to sampling each millisecond. The variety of acquired messages will also be chosen, corresponding to sampling as soon as for each specified variety of messages acquired.

Debug response: If checked, the message content material is printed within the JMeter response. This choice is especially used for debugging functions. It is not advisable to run the check formally when checked to be able to keep away from affecting the check effectivity.

MQTT disconnect sampler (MQTT DisConnect)

Disconnects the MQTT connection established within the connection sampler.

(Chongyuan Yin, CC BY-SA 4.0)

For flexibility, the property values within the above sampler can consult with JMeter’s system or customized variables.

MQTT and JMeter

In this text, I’ve launched the varied check parts of the JMeter MQTT plug-in. In one other article, I’ll talk about intimately the best way to construct check scripts with the MQTT plug-in for various check situations.


This article initially appeared on How to Use the MQTT Plug-in in JMeter and is republished with permission.

Exit mobile version