Networking & IoT · Interview question

What reachability problem does a CoAP device face that an MQTT device doesn't?

A strong answer

In the typical CoAP model the device acts as a server, clients send it requests (GET a reading, PUT a setting) and it responds, which means the client must be able to reach the device by address. But constrained IoT devices are usually behind NAT or a firewall, which blocks unsolicited inbound connections, so a cloud client generally cannot initiate a request to a CoAP device sitting on a home or cellular network; the device has no public reachable address. MQTT sidesteps this entirely because its device is a client that makes an outbound connection to a broker and keeps it open, so commands and data flow over that device-initiated connection without anything needing to reach inbound, NAT-friendly by design. To make CoAP work in NAT'd deployments you typically need the device to be on a reachable network, or to place a proxy/gateway with a public address that the device registers with, or to use Observe established from a reachable side, or to tunnel, none of which is needed in MQTT's dial-out model. So the practical takeaway is: if your devices are behind NAT and must be commanded from the cloud, MQTT's outbound model is simpler, whereas CoAP shines on reachable/local networks (e.g., a gateway querying local sensors) or with a proxy. It's the same NAT-inbound limitation from IP addressing, and it's the main architectural reason to pick one protocol over the other.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

CoAP

REST for tiny devices: CoAP brings HTTP-like GET/POST/PUT/DELETE to constrained nodes over UDP with a 4-byte header, optional confirmable reliability, Observe push, and DTLS security.

More CoAP questions

Browse all 472 interview questions
What reachability problem does a CoAP device face that an MQTT device doesn't? | EmbeddedPrep.io