MyQtt-Client : command line MQTT client manual (myqtt-client)

Index

Introduction

MyQtt-Client (myqtt-client) is a command line MQTT client built on top of libMyQtt which provides some ready to use functions to interact with MQTT servers.

Here are examples on how to use the tool. For more information, please use: myqtt-client –help

Subscribing topics

Use the following command to subscribe to a given topic with a particular QoS:

>> myqtt-client --host localhost --port 1883 --client-id test_01 --subscribe "0,myqtt/this/is/a/test"

Getting all messages received because server configuration and topics subscribed

Use the following command will show all messages as they are received, leaving the client blocked.

>> myqtt-client --host localhost --port 1883 --client-id test_01 --get-msgs

Publishing to a particular topic

>> myqtt-client --host localhost --port 1883 --client-id test_01 --publish "0,myqtt/this/is/a/test,This is a test message"

Login using username and password

You can implement any of the mentioned operations by using the following options to provide username (–username) and password (–password):

>> myqtt-client --host localhost --port 1883 --client-id test_01 --username my-login --password my-secret --publish "0,myqtt/this/is/a/test,This is a test message"

MQTT Matching topic filters from the command line

In the case you need to do some testing or you are developing an application that needs to match topics with a given filter without running an actual MQTT test, use the following:

>> myqtt-client -c '+/accounts' 'balance/accounts'

Sending MQTT ping to server from the command line

Use the following code code to send a ping to the server:

>> myqtt-client --host localhost --port 1883 --client-id test_01 --ping

Transport selection for MQTT connection

Use -l or –protocol to select the kind of protocol to use while connecting to the remote server.

mqtt (default) : plain MQTT protocol
mqtt-tls : plain MQTT protocol over TLS/SSL
mqtt-ws : plain MQTT protocol over WebSocket
mqtt-wss : plain MQTT protocol over Secure WebSocket