CoAP · Study deck

CoAP Observe: Subscriptions and Updates

A thermostat needs fresh changes, not a flood of copies after a link returns.

Broker Bex is your guide for this deck.

observe
Broker Bex, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Implement Server Push: Configure and build CoAP Observe for real-time notifications using RFC 7641
  • Design Observer Registries: Construct server-side data structures to manage registration, notifications, and deregistration lifecycle
  • Calculate Bandwidth Savings: Apply formulas to quantify Observe benefits over traditional polling for specific IoT scenarios
  • Diagnose Edge Cases: Identify and resolve NAT timeout, token reuse, and ghost observer problems in deployed systems
iotclass.org

Major section

In 60 Seconds

The useful result is a fresh change at the right pace, not merely an open subscription.

  • A protocol means the shared rules for a message exchange.
  • A broker means a service that receives and forwards named messages.
  • Telemetry means measured status sent from a device.
  • CoAP means Constrained Application Protocol, a compact system for small devices.

Key terms

MQTT
MQTT means Message Queuing Telemetry Transport, a broker-based system.

Why it matters

The CoAP Observe extension (RFC 7641) enables server-push notifications by letting a client register interest in a resource once, then automatically receiving updates whenever the value changes.

iotclass.org

Major section

In 60 Seconds (continued)

MQTT means Message Queuing Telemetry Transport, a broker-based system.

  • Register one observer, change the value, lose a notification, reconnect, and remove the observer.
  • This runway does not prove every push design or energy saving.
  • This eliminates polling overhead -- instead of 8,640 GET requests per day for 10-second updates, the server pushes only on change, reducing traffic by 90%+ for slowly-changing sensor data.
iotclass.org

Major section

Start With the Quiet Thermostat

A thermostat does not need to ask a room sensor the same question every ten seconds when the temperature barely changes.

  • It needs one registration, then a trustworthy update only when the value crosses a meaningful boundary.
  • Observe is that subscription story for CoAP.
  • The chapter builds from the simple "tell me when it changes" promise into registries, notification pacing, cleanup, edge cases, and evidence that the push stream saves energy instead of creating a flood.
iotclass.org

Major section

Phoebe's Field Notes: Count Radio Wakes, Not Only Bytes

If each wake-transmit-sleep cycle costs about 3.00 mJ, energy falls from 4.32 to 0.723 J/day, an 83.3% event-energy saving.

  • A 225 mAh, 3.0 V cell stores 2,430 J, so the same ledger gives 563 versus 3,361 idealised days.

Numbers to remember

3.0 V3.0 V cell stores 2,430 J
430 J3.0 V cell stores 2,430 J

Why it matters

That differs from the chapter's 89.3% byte saving because wake overhead does not shrink with payload size.

iotclass.org

Major section

For Beginners: Understanding Observe vs Polling

You keep asking the same question over and over, even if the answer hasn't changed.

  • You ask once, then relax - they'll let you know when something changes.
  • Battery life: Every time a device sends a message, it uses power.
  • With Observe, you might only send 10 messages when values actually change.

Numbers to remember

6.6 kBObserve (10 changes/hour): 1 registration + 240 notifications, about 6.6 kB
Sequence diagram comparing CoAP polling (repeated GET requests) versus Observe pattern (single registration with change-driven notifications), showing reduced message exchange with Observe
Sequence diagram comparing CoAP polling (repeated GET requests) versus Observe pattern (single registration with change-driven notifications), showing reduced message exchange with Observe
iotclass.org

Major section

Putting Numbers to It

We can quantify the exact bandwidth savings.

  • Multiple clients can observe one resource, but each relationship needs its own retained state; the next sections trace registration and notification behavior inside that contract.
CoAP Observe state contract across client, wire, and server, including registry retention, ordering, failure ownership, and bounded acceptance evidence
CoAP Observe state contract across client, wire, and server, including registry retention, ordering, failure ownership, and bounded acceptance evidence
iotclass.org

Major section

Observe Protocol Flow

A notification is useful only if the client can prove that it belongs to the relationship and is fresher than what it already accepted.

  • Token continuity identifies the observation, while Observe values and freshness rules help reject stale or reordered updates; a transport ACK confirms delivery but does not by itself prove that the application accepted the value.
CoAP Observe evidence lifecycle from registration through ordered notifications, cancellation or loss, and re-registration with reconciliation
CoAP Observe evidence lifecycle from registration through ordered notifications, cancellation or loss, and re-registration with reconciliation
iotclass.org

Major section

Observe Protocol Flow (continued)

Cancellation or relationship loss ends that state, and re-registration requires reconciliation.

  • Client -> Server: RST (stop this observation).
  • Timeout (Max-Age expiration):: Keep one practical point in view: If the client does not refresh the observation within Max-Age,.
  • If the client does not refresh the observation within Max-Age, the server removes that observer entry.
iotclass.org

Deck summary

Key takeaways

The useful result is a fresh change at the right pace, not merely an open subscription.

  • MQTT means Message Queuing Telemetry Transport, a broker-based system.
  • A thermostat does not need to ask a room sensor the same question every ten seconds when the temperature barely changes.
  • If each wake-transmit-sleep cycle costs about 3.00 mJ, energy falls from 4.32 to 0.723 J/day, an 83.3% event-energy saving.
  • You keep asking the same question over and over, even if the answer hasn't changed.
iotclass.org

Retrieval practice

Recall check 1 of 4

Broker Bex says: answer from memory, then check your reasoning.

Q1A CoAP Observe design replaces polling for a fast-changing sensor. What evidence should be reviewed before accepting it?

APolling reduction only, with no lifecycle evidence
BNo deregistration path and unlimited notify bursts
CRegistration lifetime, pacing limits, and cleanup behavior
DFixed update-on-every-delta behavior for all sensors
Show answer

Answer: C CoAP Observe review should cover registration lifecycle, notification control, network state, and protocol trade-offs.

iotclass.org

Retrieval practice

Recall check 2 of 4

Broker Bex says: answer from memory, then check your reasoning.

Q2A client sends GET /temperature with Observe: 0 and Token: 0xAB12. The server responds with Observe: 47. What does the value 47 in the server's response represent?

AThe number of registered observers currently tracking this resource
BA sequence value used to reject stale or out-of-order notifications
CThe Max-Age value in seconds before the observation expires
DThe port number the server will use to send future notifications
Show answer

Answer: B Correct!

iotclass.org

Retrieval practice

Recall check 3 of 4

Broker Bex says: answer from memory, then check your reasoning.

Q3Complete the CoAP observe subscription for real-time updates:

Arequest = Message(code=GET, uri='coap://sensor.local/temp', observe=0)
Brequest = Message(code=OBSERVE, uri='coap://sensor.local/temp')
Crequest = Message(code=GET, uri='coap://sensor.local/temp', subscribe=True)
Drequest = Message(code=SUBSCRIBE, uri='coap://sensor.local/temp')
Show answer

Answer: A CoAP Observe uses observe=0 in the GET request to register for notifications.

Q4What information must the server store for each observer in the observer registry?

AClient IP only, without token or timeout
BClient address, token, time, and timeout
CClient username, password, and session PIN
DFull GET replay body and debug log
Show answer

Answer: B Correct!

iotclass.org

Retrieval practice

Recall check 4 of 4

Broker Bex says: answer from memory, then check your reasoning.

Q5A CoAP server has 100 clients observing a temperature resource. The resource changes rapidly (10 times/second). What problem will occur and how should you fix it?

ANo problem - servers can handle unlimited notifications
BClients will miss notifications - use CON instead of NON
CNotification flood - add rate limits and change thresholds
DMemory exhaustion - limit number of observers
Show answer

Answer: C Correct!

iotclass.org

Print reference

Answers

Answer key.

  1. C · CoAP Observe review should cover registration lifecycle, notification control, network state, and protocol trade-offs.
  2. B · Correct!
  3. A · CoAP Observe uses observe=0 in the GET request to register for notifications.
  4. B · Correct!
  5. C · Correct!
iotclass.org