Skip to main content

MQTT Keyword Library Robot Framework

Project description

MQTTLibrary is a Robot Framework library that provides keywords for testing on MQTT brokers. MQTT is a lightweight protocol for machine-to-machine communication, typically used for IoT messaging. This library uses the paho client library published by eclipse project.


MQTTLibrary can be installed using pip:

pip install robotframework-mqttlibrary

You can also install it from the source distribution by running:

python install

You may need to run the above command with administrator privileges.


Import the library:

*** Settings ***
Library          MQTTLibrary

Connect to the broker, publish and disconnect:

*** Test Cases ***
    Publish     topic=test/mqtt_test    message=test message
    [Teardown]  Disconnect

Connect to the broker, subscribe and validate that a message is received:

*** Test Cases ***
Subscribe and Validate
    Subscribe and Validate  topic=test/mqtt_test    qos=1   payload=test
    [Teardown]              Disconnect

Keyword documentation is available at:

Also look at tests folder for examples.

For general information about using test libraries with Robot Framework, see Robot Framework User Guide.


The keywords in this library are based on some of the methods available in eclipse paho client library. If you’d like to add keywords, see instructions on creating/updating libraries for Robot Framework.

The tests are in tests folder and make use of Robot Framework itself. They are run automatically through travis when code is pushed to a branch. When run locally, these tests rely on locally running mqtt brokers. We need 2 running brokers, one without auth that is used by most of the tests, and the other one with auth (configuration file is provided). You’ll need to start them before running the tests. You can then run the tests locally:

docker pull eclipse-mosquitto
docker run -d -p 1883:1883 eclipse-mosquitto
docker run -d -p 11883:1883 -p 9001:9001 -v $(pwd)/mosquitto:/mosquitto/config eclipse-mosquitto
robot -P src tests

Make sure to stop the docker container when it is no longer needed.


MQTTLibrary is open source software provided under the Apache License 2.0.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for robotframework-mqttlibrary, version 0.7.1.post3
Filename, size File type Python version Upload date Hashes
Filename, size robotframework_mqttlibrary-0.7.1.post3-py2-none-any.whl (11.7 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size robotframework_mqttlibrary-0.7.1.post3-py3-none-any.whl (11.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size robotframework-mqttlibrary-0.7.1.post3.tar.gz (10.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page