AWS, IoT

< 1 min

AWS IoT Core Direct Messaging: Lower-Cost Server-to-Device Communication with Better Observability

Voiced by Amazon Polly

Introduction

Point-to-point communication between backend systems and individual IoT devices is common — a firmware update, a transaction update, or a command sent to one device rather than many subscribers. Historically, this meant publishing to an MQTT topic the device subscribed to, with no built-in confirmation of receipt.

AWS IoT Core offers a purpose-built way to handle this pattern: direct messaging, sent straight to a device by its MQTT client ID, with an optional acknowledgement from the device itself. This blog explains how it works and how to start using it.

Ready to lead the future? Start your AI/ML journey today!

  • In- depth knowledge and skill training
  • Hands on labs
  • Industry use cases
Enroll Now

Why Direct Messaging Matters for IoT Communication

Traditional publish-subscribe (Pub-Sub) messaging is built for fan-out to many subscribers. For one-to-one interactions, a successful publish only confirms that the broker accepted the message, not that the device received it.

Key reasons why direct messaging matters include:

  • Point-to-point routing removes unnecessary topic fan-out
    • Delivery acknowledgement comes directly from the device
    • Immediate errors reveal offline or unauthorised devices
    • Lower cost for high-volume one-to-one messaging

This lets AWS IoT Core enable simpler, more cost-effective server-to-device workflows.

Benefits of AWS IoT Core Direct Messaging

Point-to-Point Routing:
Messages route directly to a device by MQTT client ID, skipping subscription matching and fan-out.

Built-In Delivery Confirmation:
Optional quality of service 1 delivery lets AWS IoT Core wait for the device’s PUBACK before confirming success.

Immediate Offline Feedback:
If the device isn’t connected, the API returns an error immediately instead of a false success.

Lower Messaging Cost:
A single direct-message call replaces the separate publish-in, publish-out, and publish-ack operations.

No Device-Side Changes:
Messages are delivered over the device’s existing MQTT connection, so no firmware updates are required.

Understanding Direct Messaging Architecture

Direct messaging involves two sides: the sender issuing the request, and the receiver already connected to AWS IoT Core.

Sender Side (Backend Server):

  • Calls SendDirectMessage with a target client ID and topic
    • Chooses whether to request delivery confirmation
    • Authenticates via an IAM or IoT policy

Receiver Side (IoT Device):

  • Stays connected over its existing MQTT session
    • Needs no topic subscription to receive a message
    • Requires IoT: Receive permission on the target topic

This lets AWS IoT Core route each message point-to-point without the fan-out used by Pub-Sub.

Message Flow Overview

  1. A server calls SendDirectMessage with the client ID and payload.
  2. AWS IoT Core resolves the client ID to an active connection.
  3. The message routes point-to-point, skipping subscription matching.
  4. With confirmation requested, IoT Core delivers at quality of service 1 and awaits PUBACK.
  5. The device receives the message on its existing connection.
  6. IoT Core returns a status code and, if enabled, a CloudWatch Logs entry.

This keeps delivery, confirmation, and observability tied to a single API call.

How Direct Messaging Works

Direct messaging supports two delivery modes, chosen with the confirmation parameter.

  1. Without Delivery Confirmation (QoS 0):
  • Dispatched at QoS 0, returning 200 OK immediately
    • No PUBACK is required from the device
  1. With Delivery Confirmation (QoS 1):
  • IoT Core waits for the PUBACK before responding
    • Returns a 504 error if the device doesn’t acknowledge

Choosing between modes balances latency and cost against guaranteed delivery.

Getting Started with Direct Messaging on AWS

Step 1: Configure Authorization
Grant the sender iot:SendDirectMessage and the receiver iot:Receive.

Step 2: Identify the Target Client and Topic
Confirm the device’s MQTT client ID and choose a topic.

Step 3: Send the Direct Message
Call the API using curl, the CLI, or an SDK.

Step 4: Handle the Response
Check the status code returned and branch retry logic accordingly.

Step 5: Receive the Message on the Device
The existing MQTT client receives it, with no new subscription needed.

Step 6: Monitor with CloudWatch
Enable logging to capture events and failure reasons automatically.

Best Practices

  • Request confirmation only when a guaranteed acknowledgment is worth the latency.
  • Set timeouts based on realistic device wake and response cycles.
  • Enable CloudWatch logging to capture failure reasons automatically.
  • Build idempotent handlers, since a timeout leaves delivery status ambiguous.
  • Use Pub-Sub with persistent sessions for offline message queuing.

Use Cases

Server-to-Device Commands
Lock a vehicle, toggle an appliance, or push a configuration change.

Firmware and Transaction Updates
Deliver targeted updates without a full publish-subscribe-acknowledgment cycle.

Real-Time Notifications
Send time-sensitive alerts and learn immediately if a device is offline.

Connectivity and Fleet Monitoring
Track which devices are online using response codes and CloudWatch logs.

Key Advantages of Direct Messaging

  • Removes fan-out overhead for one-to-one messaging
    • Confirms delivery from the device, not just the broker
    • Lowers cost for high-volume point-to-point communication
    • Requires no firmware changes on connected devices
    • Surfaces actionable HTTP codes and CloudWatch logs

Conclusion

AWS IoT Core direct messaging gives backend systems a purpose-built way to reach one device, combining point-to-point routing with device-verified confirmation.

Teams building custom acknowledgment layers on Pub-Sub can use direct messaging to lower cost, simplify retries, and clarify delivery failures.

 

Upskill Your Teams with Enterprise-Ready Tech Training Programs

  • Team-wide Customizable Programs
  • Measurable Business Outcomes
Learn More

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As an AWS Premier Tier Services Partner, AWS Advanced Training Partner, Microsoft Solutions Partner, and Google Cloud Platform Partner, CloudThat has empowered over 1.1 million professionals through 1000+ cloud certifications, winning global recognition for its training excellence, including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 14 awards in the last 9 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, Security, IoT, and advanced technologies like Gen AI & AI/ML. It has delivered over 750 consulting projects for 850+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

FAQs

1. What is AWS IoT Core direct messaging?

ANS: – An API that sends a message to a device by its MQTT client ID.

2. How is it different from Pub-Sub?

ANS: – It skips subscription matching and confirms delivery straight from the device.

3. Does it require firmware changes?

ANS: – No, messages use the device’s existing MQTT connection.

4. What happens if the device is offline?

ANS: – The API returns an error immediately instead of a false success.

WRITTEN BY Maan Patel

Maan Patel works as a Research Associate at CloudThat, specializing in designing and implementing solutions with AWS cloud technologies. With a strong interest in cloud infrastructure, he actively works with services such as Amazon Bedrock, Amazon S3, AWS Lambda, and Amazon SageMaker. Maan Patel is passionate about building scalable, reliable, and secure architectures in the cloud, with a focus on serverless computing, automation, and cost optimization. Outside of work, he enjoys staying updated with the latest advancements in Deep Learning and experimenting with new AWS tools and services to strengthen practical expertise.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!