ipdetecto.com logo
ipdetecto.com
My IPSpeed
Knowledge Hub
HomeKnowledge HubWhat Is Mqtt And Ip Addresses
© 2026 ipdetecto.com
support@ipdetecto.comAboutContactPrivacyTermsllms.txt
Advanced
5 MIN READ
Apr 13, 2026

What Is MQTT and How Does It Use IP Addresses?

MQTT is the publish-subscribe protocol powering IoT devices worldwide. Learn how it uses IP addresses, why it outperforms HTTP for sensors, and how to secure your broker deployments.

What MQTT Is and Why It Was Created

MQTT — Message Queuing Telemetry Transport — is a publish-subscribe messaging protocol designed for constrained devices and low-bandwidth, high-latency, or unreliable networks. It was created in 1999 by Andy Stanford-Clark (IBM) and Arlen Nipper (Cirrus Link) to monitor oil pipelines via satellite. Today it is the dominant protocol for Internet of Things (IoT) device communication, supported natively in cloud platforms from AWS, Azure, Google Cloud, and hundreds of embedded device SDKs.

The protocol's design philosophy is minimum bandwidth, minimum battery drain. An MQTT control packet can be as small as 2 bytes. Compare that to an HTTP request, which adds at minimum several hundred bytes of headers even for a simple GET. For a temperature sensor that wakes up every 30 seconds to transmit a 10-byte reading, this difference matters enormously for battery life and network capacity when multiplied across thousands of devices.

The Publish-Subscribe Model and IP Addresses

MQTT does not use direct device-to-device communication. Every message passes through a central server called a broker. The broker has a fixed IP address (or a DNS hostname that resolves to one) because all devices in the network need to find and maintain connections to it.

The architecture works like this:

  • Publishers are devices that send data. A temperature sensor publishes a reading to the broker on a specific topic, such as home/livingroom/temperature.
  • Subscribers are devices or applications that receive data. Your smartphone app subscribes to home/livingroom/temperature and receives each new reading the sensor publishes.
  • The broker sits in the middle at a known IP address, routing messages from publishers to all matching subscribers. It maintains the list of subscriptions and queues messages when subscribers are temporarily offline.

A device only needs to know one IP address: the broker's. It never needs to know the IP addresses of other devices. This decoupling is one of MQTT's key architectural advantages — devices can be added, removed, or replaced without reconfiguring other devices in the network.

MQTT at the Network Layer

MQTT runs over TCP/IP. The default port is 1883 for unencrypted connections. For TLS-encrypted connections, the standard port is 8883. MQTT over WebSockets (for browser-based clients) uses port 80 or 443 depending on TLS.

The TCP connection is persistent. Unlike HTTP where each request creates a new connection, MQTT clients establish a single TCP connection to the broker and maintain it for the duration of their session. This persistent connection eliminates the latency and overhead of repeated TCP handshakes and TLS negotiations, which is critical for time-sensitive sensor data and command-and-control traffic.

When a device cannot maintain a persistent connection (due to cellular network constraints or power management), MQTT's clean session and persistent session features allow the broker to queue messages for the device until it reconnects.

MQTT Topic Structure

Topics are hierarchical UTF-8 strings that define where messages are published and subscribed. They use forward slashes as separators:

  • factory/line1/machine3/temperature
  • home/kitchen/humidity
  • building/floor3/hvac/status

Subscribers can use wildcards to subscribe to multiple topics at once:

  • + (single level wildcard): home/+/temperature matches home/kitchen/temperature, home/bedroom/temperature, etc.
  • # (multi-level wildcard): home/# matches everything under home/ including all nested levels.

Good topic design is critical for both performance and security. Overly broad subscriptions (like subscribing to #) generate unnecessary traffic and can expose data to unintended subscribers.

Quality of Service Levels

MQTT defines three QoS levels that trade message delivery guarantee against overhead:

QoS LevelGuaranteeOverheadBest For
QoS 0 (At most once)Message sent once, no acknowledgmentLowestSensor readings where occasional loss is acceptable
QoS 1 (At least once)Message delivered at least once, may duplicateModerate (acknowledgment packet)Commands, alerts where delivery is required
QoS 2 (Exactly once)Message delivered exactly once, no duplicatesHighest (4-packet handshake)Billing events, financial transactions

For most sensor telemetry, QoS 0 or QoS 1 is appropriate. QoS 2 is used sparingly because the 4-packet exchange significantly increases latency and broker load.

MQTT vs. HTTP vs. CoAP for IoT

ProtocolModelMin Packet SizeConnectionBest For
MQTTPublish-subscribe2 bytesPersistent TCPMany devices, low power, real-time telemetry
HTTP/RESTRequest-response~200 bytesNew per request (HTTP/1.1)Cloud API calls, web dashboards
CoAPRequest-response4 bytesUDP, connectionlessConstrained devices on lossy networks
AMQPMessage queue~8 bytesPersistent TCPEnterprise message routing, complex routing rules
WebSocketBidirectional stream~6 bytesPersistentBrowser-based real-time applications

Popular MQTT Brokers

Mosquitto is the most widely used open-source MQTT broker, maintained by the Eclipse Foundation. It is lightweight, runs on hardware as small as a Raspberry Pi, and supports MQTT 3.1.1 and 5.0. Mosquitto is suitable for development and small to medium IoT deployments.

EMQX is a high-performance open-source broker designed for large-scale deployments, supporting millions of concurrent connections with clustering and horizontal scaling. It includes a web-based management console and REST API for monitoring.

HiveMQ is a commercial broker optimized for enterprise deployments with advanced security features, Kubernetes support, and compliance certifications.

Cloud-managed MQTT services include AWS IoT Core, Azure IoT Hub, and Google Cloud IoT Core, which handle broker infrastructure, scaling, and integration with cloud processing services without requiring self-hosted broker management.

Securing MQTT: Critical Considerations

Default MQTT configurations are often completely open — no authentication, no encryption, port 1883 accessible to anyone with network access. This was acceptable on isolated industrial networks but is dangerous on any internet-connected deployment. Securing an MQTT deployment requires:

  • TLS encryption: Use port 8883 with valid certificates. Without TLS, all MQTT traffic including credentials is transmitted in plaintext. Any network observer can capture and inject messages.
  • Authentication: Configure username and password authentication at minimum. For production, use client certificate authentication (mutual TLS) so each device has a cryptographically verified identity.
  • Authorization: Restrict which topics each client can publish to and subscribe from. A temperature sensor should not be able to subscribe to command topics. Brokers support ACL (Access Control List) configuration to enforce per-client topic permissions.
  • Firewall rules: If the broker is on the public internet, restrict port 8883 access to known client IP ranges where possible. Monitoring for unauthorized connection attempts is also important.

MQTT 5.0 vs. 3.1.1

MQTT 5.0 (released 2019) added significant features over the widely deployed 3.1.1:

  • Reason codes: All responses include a reason code explaining success or failure, replacing the ambiguous success/failure of 3.1.1.
  • User properties: Key-value metadata can be attached to any MQTT message, enabling use cases like message tracing and custom routing.
  • Shared subscriptions: Multiple subscribers can share a subscription group, with the broker distributing messages across them — enabling load-balanced processing without requiring a separate message queue.
  • Message expiry: Messages can be given an expiry time, after which the broker discards them if undelivered. Prevents stale commands from executing after reconnect.
  • Flow control: Clients can specify the maximum number of unacknowledged QoS 1 and 2 messages, preventing broker overload on slow connections.

Common Misconceptions

MQTT and HTTP are interchangeable for IoT

They are not. HTTP follows a request-response model — a client asks for data and a server responds. MQTT uses publish-subscribe — publishers send data when it changes and subscribers receive it immediately without polling. For IoT devices that generate continuous telemetry, HTTP polling generates enormous overhead (repeated connections, headers, repeated authentication). MQTT's persistent connection and minimal overhead make it the right choice for high-frequency sensor data.

The broker is a single point of failure

In a poorly designed deployment, yes. But enterprise MQTT brokers like EMQX and HiveMQ support clustered deployments with redundant nodes and automatic failover. Cloud-managed services like AWS IoT Core are inherently highly available. The broker is architecturally central but does not have to be a reliability bottleneck if designed correctly.

MQTT is only for small devices

MQTT is optimized for constrained devices, but it is equally appropriate for server-to-server messaging, microservice event streaming, and real-time dashboard data delivery. Any scenario where you want one-to-many message distribution with persistent connections and low overhead is a valid MQTT use case regardless of device type.

QoS 2 is always the safest choice

QoS 2 guarantees exactly-once delivery, which sounds ideal, but the 4-packet handshake multiplies broker and network load. For sensor telemetry where occasional duplicate readings are harmless, QoS 2 wastes resources. For commands or financial events, QoS 2 is justified. Choose QoS based on your specific message semantics, not a blanket assumption that higher is better.

Pro Tips

  • Always give your broker a stable hostname, not just an IP address. Device firmware is hard to update. If your broker's IP changes, every device needs a firmware update. A DNS hostname provides flexibility to change the underlying IP without touching device configuration.
  • Design topic hierarchies before deployment, not after. Retrofitting topic structure after hundreds of devices are deployed requires firmware updates across your entire fleet. Plan the hierarchy, document it, and treat it as a formal schema that requires change control.
  • Enable retained messages for device state topics. A retained message means the broker stores the last published value for a topic and immediately delivers it to any new subscriber. New subscribers and reconnecting clients immediately know the current device state without waiting for the next publish.
  • Use Last Will and Testament (LWT) for device health monitoring. LWT allows a device to register a message with the broker that will be published automatically if the device disconnects unexpectedly. Subscribe to LWT topics to detect ungraceful disconnects that indicate power loss, network failure, or device crash.
  • Monitor broker connection counts and message rates continuously. An unexpected spike in new connections may indicate a firmware bug causing devices to repeatedly reconnect. A drop in expected message rates may indicate silent device failure. These metrics are the primary operational signals for IoT fleet health.
  • Separate test and production broker infrastructure completely. Test devices publishing to a production broker — or production devices accidentally pointed at a test broker after a configuration mistake — cause subtle data corruption that is difficult to trace. Separate broker instances, separate network segments, separate credentials.

Explore your current network connection and device IP details here.

Frequently Asked Questions

Q.What is MQTT and what does it stand for?

MQTT stands for Message Queuing Telemetry Transport. It is a lightweight publish-subscribe messaging protocol designed for constrained devices and low-bandwidth networks. Created in 1999 for monitoring oil pipelines via satellite, it is now the dominant protocol for IoT device communication, supported by AWS IoT Core, Azure IoT Hub, and hundreds of device SDKs.

Q.What port does MQTT use?

MQTT uses port 1883 for unencrypted connections and port 8883 for TLS-encrypted connections. MQTT over WebSockets uses port 80 (unencrypted) or 443 (TLS). Port 8883 should be used for any internet-connected deployment — port 1883 transmits all data including credentials in plaintext.

Q.What is an MQTT broker and why does it need a fixed IP?

The MQTT broker is a central server that routes messages from publishers to subscribers. Every device in the MQTT network connects to the broker rather than directly to other devices. The broker needs a stable IP address or DNS hostname because all devices need a fixed connection point. Devices only need to know the broker's address — they never need to know each other's IP addresses.

Q.What are MQTT QoS levels?

MQTT defines three Quality of Service levels. QoS 0 (at most once) sends a message with no acknowledgment — fastest but may lose messages. QoS 1 (at least once) ensures delivery with acknowledgment but may duplicate messages. QoS 2 (exactly once) guarantees each message is delivered exactly once using a 4-packet handshake — highest reliability but highest overhead.

Q.How is MQTT different from HTTP for IoT devices?

HTTP uses request-response — a client asks for data and waits for a response. MQTT uses publish-subscribe — publishers send data when available and subscribers receive it immediately without polling. MQTT maintains a persistent TCP connection, eliminating repeated connection overhead. Minimum MQTT packet size is 2 bytes versus several hundred bytes for HTTP. For continuous sensor telemetry, MQTT uses significantly less bandwidth and battery power.

Q.What is an MQTT topic?

An MQTT topic is a hierarchical UTF-8 string that identifies the subject of a message, using forward slashes as separators (like home/livingroom/temperature). Publishers send messages to topics. Subscribers specify which topics to receive. Wildcards + (single level) and # (multi-level) allow subscribing to multiple topics at once. Well-designed topic hierarchies are critical for both performance and access control.

Q.What is an MQTT Last Will and Testament?

Last Will and Testament (LWT) allows a device to register a message with the broker at connection time that will be automatically published if the device disconnects unexpectedly (without sending a proper DISCONNECT packet). Other subscribers receive the LWT message as a notification that the device went offline unexpectedly, enabling real-time device health monitoring across an IoT fleet.

Q.What is a retained message in MQTT?

A retained message is a message flagged so the broker stores the last published value for that topic. Any new subscriber immediately receives the most recent retained message upon subscribing, without waiting for the next publish event. Retained messages are useful for device state topics like current temperature or on/off status, where subscribers need the current value upon connecting.

Q.How do I secure an MQTT broker?

Use TLS on port 8883 to encrypt all traffic. Enable username and password authentication or prefer client certificate authentication for cryptographic device identity verification. Configure ACLs to restrict each client to only the topics it needs to publish and subscribe. Firewall port 8883 to known IP ranges where possible. Never expose port 1883 to the public internet.

Q.What is the difference between MQTT 3.1.1 and MQTT 5.0?

MQTT 5.0 adds reason codes for all responses (replacing ambiguous pass/fail), user-defined message properties for metadata, shared subscriptions for load-balanced processing, message expiry to discard stale messages, and per-client flow control. MQTT 3.1.1 remains widely deployed for backward compatibility. New deployments should use MQTT 5.0 where broker and client SDK support is available.

Q.What is the best open-source MQTT broker?

Mosquitto (Eclipse Foundation) is the most widely used open-source broker, suitable for development and moderate-scale deployments. EMQX is the preferred choice for large-scale deployments requiring millions of concurrent connections, clustering, and a management console. Both support MQTT 3.1.1 and 5.0 with TLS and authentication.

Q.Can MQTT work without internet connectivity?

Yes. MQTT only requires TCP/IP connectivity between devices and the broker. The broker can be on a local network with no internet access. This is common in industrial environments where devices communicate with a local broker on the factory LAN without any cloud connectivity. Local-only deployments are also lower latency since messages do not traverse the internet.

Q.How does MQTT handle devices that go offline temporarily?

MQTT supports persistent sessions where the broker retains subscription information and queues QoS 1 and 2 messages while a client is offline. When the client reconnects with its previous client ID and clean session set to false, the broker delivers queued messages. Clean sessions discard all state on disconnect. Persistent sessions enable reliable delivery to intermittently connected devices.
TOPICS & TAGS
mqttiot protocolnetworking advancedmessage brokersmart home techwhat is mqtt and how it uses ip addresses 2026the lightweight messenger language of the iot worldallowing tiny low power devices to talk over ip netsmqtt vs http comparison for smart home technologyunderstanding the publish subscribe broker model for speedhow a central broker ip manages thousands of sensorsit guide to zero overhead communication for lightbulbsthe gold standard for internet of things device speedwhy your smart home feels so fast and responsive todaytechnical tutorial for setting up an mqtt message brokerimpact of mqtt on battery life and network bandwidthsecuring the sensor conversations in your smart buildingexpert tips for choosing a fixed ip for your iot brokerexpert guide to mqtt topics and device synchronizationMQTT QoS levels explainedMQTT broker Mosquitto setupMQTT vs AMQP vs CoAP comparisonMQTT TLS securityMQTT topic structure best practicesMQTT last will testamentMQTT retained messagesMQTT 5.0 vs 3.1.1