MQTT Client Command Line Application for Windows, OSX and Linux

MQTT Client Commands

MQTT publish subscribe architecture

The MQTT messages are delivered asynchronously (“push”) through publish subscribe architecture.

MQTT 3.1.1 and 5.0

Component supports MQTT 3.1.1 protocol and latest 5.0 protocol.

Quality of Service (QoS) for MQTT

Three QoS for message delivery could be achieved using MQTT

Over TCP and WebSockets

Supports MQTT over WebSockets and over TCP (encrypted and none encrypted).

MQTT Client Win32

sgcMQTTClient Win32
MQTTClient Client Win32

MQTT Client Win64

sgcMQTTClient Win64
MQTTClient Client Win64

MQTT Client OSX64

sgcMQTTClient OSX64
MQTTClient Client OSX64

MQTT Client OSXARM64

sgcMQTTClient OSXARM64
MQTTClient Client OSXARM64

MQTT Client Linux64

sgcMQTTClient Linux64
MQTTClient Client Linux64

How Open a new MQTT connection

Example: open a tcp mqtt connection to test.mosquitto.org

{"message":"open", "params":{"url": "tcp://test.mosquitto.org:1883"}}

Example: open a websocket mqtt connection to test.mosquitto.org

{"message":"open", "params":{"url": "ws://test.mosquitto.org:8080"}}

How Subscribe / UnSubscribe

Example: subscribe to topic "myTopic"

{"message":"subscribe", "protocol":"mqtt", "params":{"topic": "myTopic"}}

Example: unsubscribe from topic "myTopic"

{"message":"unsubscribe", "protocol":"mqtt", "params":{"topic": "myTopic"}}

 

How Enable MQTT Options

Example: enable mqtt 5.0

{"message":"api", "protocol":"mqtt", "params":{"version":"5.0"}}

Example: enable authentication

{"message":"authentication", "protocol":"mqtt", "params":{"enabled":true, "username":"user", "password":"secret"}}

Example: Enable heartbeat every 30 seconds.

{"message":"heartbeat", "protocol":"mqtt", "params":{"enabled": true, "interval": 30}}

Example: Disable heartbeat

{"message": "heartbeat", "params":{"enabled": false}}

Close Connection

Example: close connection

{"message":"disconnect", "protocol":"mqtt"}

 

TCP Server

All console applications can run an internal TCP Server that allows to send and receive commands as if were written directly on the console application.

Just start the application with the command -server and a new server will be started listening on port 8080. Example: if you want enable the server on WebSocket client, start the console application as follows:

sgcWebSocketClient.exe -server

Find below the full TCP Server parameters:

-server: starts the internal server on port 8080

-server.port: sets the listening port

-server.ip: sets the binding ip (useful if there are multiple ips).

If the server is enabled, a client connected to this server can send any JSON message and will receive any response as if was written directly from console application.

Example: if you want enable server on IP 192.168.1.1 and Port 5412

sgcWebSocketClient.exe -server -server.ip 192.168.1.1 -server.port 5412