Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Use JMeter to test MQTT protocol

Shulou Source: shulou.com Published: 2022-06-03 04:24:08 10月03日 Update

1. MQTT is a client-server based message publish / subscribe transport protocol. MQTT protocol is lightweight, simple, open and easy to implement, which makes it suitable for a wide range of applications. This paper briefly introduces how to use JMeter to test the performance of MQTT protocol.

2. To test the MQTT protocol, you need to download a mqtt-xmeter-jar-with-dependencies.jar plug-in and place it in the lib/ext directory of JMeter. For the download method, see the end of the article.

First, add thread groups

 

Add thread group. Jmeter execution is driven by thread group. The test plan must have at least one thread group. Select the test plan, right-click, and add "thread" thread group.

2. Add the following request in turn

  add create connection request-select thread group, right-click to add "sampler" MQTT Connect

The request is used to connect. This time, the MQTT service enabled by this machine is used for testing, so the ip is 127.0.0.1, and the port defaults to 1883.

Add release request-select the thread group, right-click, and add the "sampler" MQTT Pub Sampler

The function of the request is to publish the message to the server. You only need to enter the subject, send the message type, and send the message content.

Add subscription request-select the thread group, right-click to add the "sampler" MQTT Sub Sampler

This request is used to subscribe to published messages. You only need to enter the topic name to subscribe.

Since we usually only need to connect once in the process of testing, we also add a controller only once. The effect of this controller is that a thread executes only once, no matter how many loops are executed. Right-click thread group "add" logical controller "only once controller"

Add view structure tree, right-click thread group, add listener, view structure tree, the function of this component is to view the specific request parameters and response results of each request

Third, execute the test

 

Click execute case to execute the developed script, and the result is as follows:

MQTT backend release record

    if the article is helpful to you, you are welcome to follow my official account, which is synchronized with the articles on this platform for easy reference. I will continue to publish articles related to testing and share testing techniques with you. Every original article is written attentively to put an end to plagiarism.

QQ technology exchange group: please enter the verification information 51CTO to add the group.

 

Wechat QR code follow official account:

 

After following, reply to the resource download, and you can get the download address of all kinds of resources shared by yourself.

Tags: Threads tests articles messages controllers controls subscriptions functions public samplers services inputs topics technologies servers building trees results resources resource downloads original articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Linux Redmi Shulou Technology