Stand with Ukraine flag

MQTT GUIDE

3 min read

What Is an MQTT Client?

Quick answer

An MQTT client is any device or application that connects to an MQTT broker to publish messages, subscribe to topics, or both. Anything from an 8-bit microcontroller to a backend service or a browser tab can be a client, as long as it speaks the MQTT protocol over a supported transport.

An MQTT client is any endpoint that connects to an MQTT broker. The protocol makes no distinction between a tiny sensor and a large backend service — if it speaks MQTT, it's a client, and the broker treats them all the same way.

How a client connects

Every client starts by sending a CONNECT packet carrying a client ID, an optional username/password, a keep-alive interval, the clean-start flag for its session, and an optional last will. The broker replies with a CONNACK that accepts or rejects the connection. After that, the client can subscribe and publish freely.

Client Broker CONNECT (clientId, …) opens session CONNACK accepted SUBSCRIBE cmd/device-1 listen PUBLISH sensors/1/temp telemetry PUBLISH cmd/device-1 command
One connection carries both directions — publish and subscribe

What a client can do

Publish — send a message to a topic (e.g. a sensor reporting a reading).
Subscribe — register interest in one or more topics and receive matching messages as they arrive.
Both — a client often does both — a device publishes telemetry and subscribes to commands on the same connection.

MQTT client libraries

You rarely implement MQTT by hand. Mature client libraries exist for virtually every language and platform — Eclipse Paho (C, Java, Python, and more), MQTT.js for Node and browsers, and vendor SDKs for microcontrollers. Because MQTT is a standard, any compliant library works with any compliant broker.

Clients in TBMQ

TBMQ works with any standard MQTT client library, and it ships a built-in WebSocket MQTT client in its UI so you can publish and subscribe straight from the browser. TBMQ also categorizes clients as DEVICE or APPLICATION types, which determines how their sessions and message queues are persisted at scale.

Frequently asked questions

What is an MQTT client?

Any device or program that connects to an MQTT broker to publish messages, subscribe to topics, or both. A temperature sensor, a mobile app, a backend service, and a browser tab can all be MQTT clients.

Can a client both publish and subscribe?

Yes. A single client can publish to some topics and subscribe to others over the same connection. Roles are per message, not per client.

What is a client ID in MQTT?

A client identifier is a string that uniquely identifies a client to the broker. It ties a connection to its session, so the broker can resume a persistent session or take over a stale one when the same ID reconnects.

Do I need a special library to build an MQTT client?

You use an MQTT client library for your language or platform (for example Eclipse Paho, MQTT.js, or a device SDK). Any library that implements the MQTT protocol works with any compliant broker.

Can a web browser be an MQTT client?

Yes, over MQTT on WebSocket. Browsers cannot open raw TCP sockets, so they connect using MQTT over WebSocket — TBMQ even ships a browser-based MQTT client in its UI.

Run it yourself

TBMQ is a free, open-source MQTT broker built to scale. Spin it up in minutes or try the live demo — no install required.