MQTT command line sample programs
The syntax and parameters of the MQTT command line sample programs .
Purpose
Publish and subscribe to a topic.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
orsubscribe
, 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
, orMessage from MQTTv3 C client
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 ispublish
orsubscribe
. - -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.