We will use the mosquitto_sub command-line utility included in Mosquitto to try to generate a simple MQTT client that subscribes to a topic and prints all the messages it receives. We will use the default configuration, to try to establish a communication with the Mosquitto server, by using the default 1883 port without a certificate authority certificate specified. Open a Terminal in macOS or Linux, or a Command Prompt in Windows, go to the directory in which Mosquitto is installed, and run the following command:
mosquitto_sub -V mqttv311 -t sensors/octocopter01/altitude -d
The mosquitto_sub utility will display the following error. The Mosquitto server is not accepting any connections on port 1883 anymore. Notice that the error message might be different depending on the platform:
Error: No connection could be made because...