CoAP · Study deck
CoAP Observe: Efficiency and Lifecycle
A network address translator (NAT) may let an idle UDP mapping expire before the next change reaches an observer, a client waiting for sensor changes.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
Keep network path, notification freshness, and observer state under review.
- Decide when Observe beats polling.
- Measure notification rate and radio wakes; size keep-alives from measured NAT lifetime.
- Match tokens after restart and honor Max-Age freshness.
- Clean up ghost observers; treat battery quotients as model outputs.
Major section
Start With the Decision
A network address translator (NAT) may let an idle UDP mapping expire before the next change reaches an observer, a client waiting for sensor changes.
- A keep-alive is a small message sent to keep that path open.
Major section
Worked Example: Industrial Vibration Monitoring with Observe
Maintenance dashboard needs real-time updates when vibration exceeds thresholds (normal: <2.5 mm/s, warning: 2.5-4.5 mm/s, critical: >4.5 mm/s).
- Critical alarm crossings bypass the routine 60-second cap, so alerts have no polling delay.
Major section
Common Mistake: Forgetting to Handle Observer Cleanup After Client Crashes
The Error: Server registers Observe subscriptions but never removes them when clients crash or restart, leading to "ghost observers" that consume memory and network bandwidth sending notifications to unreachable clients.
- When a client crashes and restarts, it may generate a new token.
Major section
Common Mistake: Forgetting to Handle Observer Cleanup After Client Crashes (continued)
The server can continue sending notifications to the old token; if the restarted client receives an unrecognized notification, it can reject it with RST.
- CON notification failures (retry limit):: This is transport pseudocode: send_datagram_once sends exactly one datagram and does not perform library-managed retransmission.
- Use CON notifications (not NON) so you detect unreachable clients.
- Use at most four retransmissions after the original CON send (RFC 7252 default).
Major section
Checkpoint: Failure Modes
You now know unknown tokens after a restart should trigger RST cleanup rather than silent drops.
- You now know UDP NAT mapping lifetimes vary, so quiet Observe streams may need client-originated keep-alives or re-registration.
- You now know RST and failed CON delivery remove ghost observers; an optional server lease is separate from Max-Age freshness.
Major section
1. Using Confirmable Messages for Every CoAP Request
CON messages require an ACK exchange.
- With RFC 7252 defaults, four retransmissions occur after randomized waits totaling 30–45 seconds; the final acknowledgement wait can extend failure detection to 62–93 seconds, regardless of any fixed packet-loss percentage.
Major section
Hands-On Practice
Exercise 2: Bandwidth Calculation: A smart building has 200 temperature sensors, each observed by 3 clients (dashboard, HVAC controller, alarm system).
- Sensors report every time temperature changes by 0.5°C.
- Estimated notifications per hour (assuming 2 significant changes per sensor per hour).
Major section
Checkpoint: Evidence Before Selection
You now know the chapter's 100-observer example can show 99% bandwidth reduction when changes are infrequent.
- You now know the vibration example's 772-day polling figure is a transmit-only charge quotient, and its Observe quotient is much larger under the same assumptions.
Deck summary
Key takeaways
A network address translator (NAT) may let an idle UDP mapping expire before the next change reaches an observer, a client waiting for sensor changes.
- Maintenance dashboard needs real-time updates when vibration exceeds thresholds (normal: <2.5 mm/s, warning: 2.5-4.5 mm/s, critical: >4.5 mm/s).
- The Error: Server registers Observe subscriptions but never removes them when clients crash or restart, leading to "ghost observers" that consume memory and network bandwidth sending notifications to unreachable clients.
- You now know unknown tokens after a restart should trigger RST cleanup rather than silent drops.
- CON messages require an ACK exchange.
Retrieval practice
Recall check 1 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q1A measured NAT mapping lasts forty seconds. The chosen safety fraction is three quarters. What keep-alive interval follows the chapter’s rule?
Show answer
Answer: A Forty seconds multiplied by three quarters gives a thirty-second interval, before mapping expiry.
Q2A client refreshes 30 NAT mappings every 30 seconds. How many refresh datagrams does it send per minute?
Show answer
Answer: C Each mapping needs a refresh each interval.
Retrieval practice
Recall check 2 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q3A CoAP client behind NAT registered for temperature updates. A gateway trace shows its UDP mapping expired during two minutes of inactivity; the client is still running and the next server notification cannot reach it. What happened and what is the direct recovery policy?
Show answer
Answer: B NAT mappings expire without traffic.
Q4A smart thermostat app wants to receive temperature updates whenever the value changes, without polling. Which CoAP feature enables this?
Show answer
Answer: C The Observe extension (RFC 7641) enables pub/sub-like behavior: client registers once, server pushes changes automatically.
Retrieval practice
Recall check 3 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q5An Observe sensor now sends a push for every tiny change. What should the review compare before claiming an energy saving?
Show answer
Answer: D Frequent pushes and recovery can erase the expected traffic and wake savings.
Retrieval practice
Recall check 4 of 4

Broker Bex says: answer from memory, then check your reasoning.
Q6What removes a CoAP observer when it no longer wants or can receive updates?
Show answer
Answer: C RST, an explicit cancel, or server timeout removes an observer that no longer wants or can receive updates.
Print reference
Answers
Answer key.
- A · Forty seconds multiplied by three quarters gives a thirty-second interval, before mapping expiry.
- C · Each mapping needs a refresh each interval.
- B · NAT mappings expire without traffic.
- C · The Observe extension (RFC 7641) enables pub/sub-like behavior: client registers once, server pushes changes automatically.
- D · Frequent pushes and recovery can erase the expected traffic and wake savings.
- C · RST, an explicit cancel, or server timeout removes an observer that no longer wants or can receive updates.