1. Publishing Messages to the MQTT Broker

Applies to ReadyAPI 3.7, last modified on April 08, 2021

This step of the MQTT Testing tutorial provides information on how to create a connection to the MQTT broker and publish the message to it.

Creating the Topic Publisher Test Case

  1. Create an empty ReadyAPI project.

  2. Add a test suite and a test case.

    ReadyAPI: The test case
  3. Add the Publish Using MQTT test step to the test case.

    ReadyAPI: Adding the Publish Using MQTT test step
  4. Open the new test step.

  5. Open the Connection drop-down list and select New Connection.

    ReadyAPI: Creating the new MQTT connection

    Click the image to enlarge it.

  6. In the Create New Connection dialog, open the General tab.

    ReadyAPI: The Create New Connection dialog
  7. Enter SampleConnection in the Name field. ReadyAPI will use this name to identify the connection.

  8. Enter broker.hivemq.com in the Server URL field.

  9. Click OK.

    Note: Other settings are optional, so you do not need to edit them now.

  10. Specify the sampletopic/samplemessage topic.

    ReadyAPI: Entering a topic for the MQTT connection

    Click the image to enlarge it.

  11. Enter the following phrase as the message contents:

    Current temperature is 30 degrees.

    ReadyAPI: Entering a message for the MQTT connection

Testing the Connection

Click on the ReadyAPI toolbar to check if the connection works.

ReadyAPI will connect to the broker and send the message you have specified in the connection properties earlier. You can expand the Test Case Log tab to see whether the message was published successfully.

ReadyAPI: The test step log

Click the image to enlarge it.

Now, you can use the Receive MQTT Message test step to receive information from the broker.

Prev     Next

See Also

About IoT MQTT Testing
MQTT Testing Tutorial

Highlight search results