NanoMQTT

NanoMQTT is the MQTT client included in TrustCore SDK (beginning with the U6 release). It supports MQTT 3.1.1 and MQTT 5, allowing your application to publish and subscribe over plain TCP (port 1883) or TLS (port 8883) by re-using TrustCore SDK NanoSSL transport.

NanoMQTT is available in two models:

License

This project is available under a dual-license model:

  • Open Source License: GNU Affero General Public License v3 (AGPL v3): This license allows you to use, modify, and distribute the code for free in accordance with AGPL terms.
  • Commercial License: If you wish to use TrustCore SDK in a proprietary or commercial product (e.g., embedded in closed-source firmware or commercial SaaS applications), a commercial license is available under DigiCert’s Master Services Agreement (MSA). Contact us at sales@digicert.com for commercial licensing details.

Key features

  • QoS 0, 1, 2 publish/subscribe with retain flag, wildcard topics, and last-will messages.
  • MQTT 5 properties on CONNECT, PUBLISH, SUBSCRIBE, UNSUBSCRIBE, WILL, and DISCONNECT packets.
  • Session control using clean start or a session-expiry interval (0 - 4 294 967 295 s).
  • Transport flexibility by using plain TCP or TLS through NanoSSL.
  • Proxy support via the --proxy flag (HTTP or HTTPS forward proxies).

Configurable limits

ItemDefaultNotes
Topic length65 535 bytesMQTT spec limit
Publish QoS level (0 / 1 / 2)0Select per message via --mqtt_pub_qos
Maximum packet size acceptedUnlimitedLimit with MQTT 5 CONNECT property max_packet_size
Receive-maximum (parallel QoS 1/2)UnlimitedLimit with MQTT 5 CONNECT property receive_maximum

Protocol compliance

Control-packet familyMQTT 3.1.1MQTT 5 (extensions)
CONNECT / CONNACK✔ (reason codes, user properties)
PUBLISH flow (ACK, REC, REL, COMP)
SUBSCRIBE / SUBACK✔ (retain-handling, retain-as-published, no-local)
UNSUBSCRIBE / UNSUBACK
DISCONNECT✔ (reason codes, session-expiry)
AUTH

Usage with other TrustCore SDK modules

ComponentUsage in NanoMQTT
NanoSSLProvides TLS record protection. Call MQTT_setTransportSSL() with an active NanoSSL connection to secure the session.
NanoCryptoSupplies hashing and cipher routines — no duplicate crypto code.
Common socket layerNanoMQTT uses the same non-blocking socket helpers as other TrustCore modules, enabling a single event loop.

Quick start

# Build the sample client (adds TLS support)
./scripts/nanomqtt/mqtt_client/build_mqtt_client.sh --ssl

# Terminal 1 — subscribe (plain TCP, port 1883)
./bin/mqtt_client_sample \
--mqtt_servername https://test.mosquitto.org/
--mqtt_port 1883 \
--mqtt_sub_topic demo/led \
--mqtt_clean_start

# Terminal 2 — publish (TLS, port 8883)
./bin/mqtt_client_sample \
--mqtt_servername https://test.mosquitto.org/
--mqtt_port 8883 \
--mqtt_transport SSL \
--ssl_ca_file /etc/ssl/certs/ca-bundle.crt \
--mqtt_pub_topic demo/led \
--mqtt_pub_message "ON" \
--mqtt_clean_start

The subscriber prints:

demo/led  ON