MQTT command line sample programs

The syntax and parameters of the MQTT command line sample programs .

Purpose

Publish and subscribe to a topic.

Syntax

Read syntax diagramSkip visual syntax diagram MQTTV3Sample1MQTTV3SSample1Sample2SampleAsyncCallBack2SampleAsyncWait2 -h-qfalse-qtrue-apublish-asubscribe-tdefault topic-ttopic name-mdefault text-mmessage text-s2-s0-s1-bdefault host name-bhost name-bIP address-p1883-pport numberPaho parametersSSL parameters3
Paho parameters
Read syntax diagramSkip visual syntax diagram-idefault client identifier-iclient identifier-ctrue-cfalse
SSL parameters
Read syntax diagramSkip visual syntax diagram-kkeystore-wkeystore passphrase-rtruststore-v0|false-v1|true
Read syntax diagramSkip visual syntax diagram
Notes:
  • 1 IBM® WebSphere® MQ sample
  • 2 Paho sample
  • 3 Not MQTTV3Sample.

Parameters

-h
Print this help text and quit
-q
Set quiet mode, instead of using the default mode of false.
-a publish|subscribe
Set the action to publish or subscribe, instead of assuming the default action of publishing.
-t topic name
Publish or subscribe to topic name, instead of publishing or subscribing to the default topic. The default topics are as follows:
Paho samples
Publish
Sample/Java/v3
Subscribe
Sample/#
IBM WebSphere MQ samples
Publish
MQTTV3Sample/Java/v3 or MQTTV3Sample/C/v3
Subscribe
MQTTV3Sample/#
-m message text
Publish message text instead of sending the default text. The default text is either Message from MQTTv3 C client, or Message from MQTTv3 Java client
-s 0|1|2
Set the quality of service (QoS) instead of using the default QoS, 2.
-b host name
Connect to host name or IP address instead of connecting to the default host name. The default host name for the Paho samples is m2m.eclipse.org. For the IBM WebSphere MQ samples it is localhost.
-p port number
Use port port number instead of using the default port, 1883.

Paho parameters

-i client identifier
Set the client identifier to client identifier. The default client identifier is SampleJavaV3_"+action, where action is publish or subscribe.
-c true|false
Set the clean session flag. The default is true: subscriptions are not durable.

SSL parameters

-k keystore
Set the path to the keystore containing the private key that identifies the client to keystore. For the C samples, the store is a Privacy-Enhanced Mail (PEM) file. For the Java samples it is a Java keystore (JKS).
-w keystore passphrase
Set the passphrase to authorize the client to access the keystore to keystore passphrase.
-r truststore
Set the path to the keystore containing the public keys of MQTT servers the client trusts to truststore. The keystore is a Privacy-Enhanced Mail (PEM) file. For the C samples, the store is a Privacy-Enhanced Mail (PEM) file. For the Java samples it is a Java keystore (JKS).
-v 0|false|1|true
Set the verify option to 1|true to require a server certificate. The default is 0|false: the server certificate is not checked. The SSL channel is always encrypted.

Set the option to 0|1 for C programs and true|false for Java programs.