Chapters

Subscriptions and Updates: CoAP Observe Reference

This page preserves the source material accompanying CoAP Observe: Subscriptions and Updates. The three diagrams and arrival table are in the chapter. The five knowledge-check blocks are preserved on the standalone check page. The source headings and examples below retain their original wording.

Start With the Decision

A thermostat registers for /temperature and receives 23.5. Later, two updates arrive in reverse order. Which value should it display, and what should it do if no fresh update arrives?

CoAP is a compact request-and-response protocol. Observe extends a GET request so the server can send later responses called notifications. The client and server retain an observation, or registration state. Work through one thermostat trace to decide whether each notification belongs to that observation, is newer, and is still fresh.

Route Overview

This is part 1 of 2. Continue with CoAP Observe: Efficiency and Lifecycle.

Part Objectives

  • Trace registration, notification, token, and sequence state.
  • Set update pace and recovery rules for a CoAP observer.
In 60 Seconds

Decide whether one update can be used.

The thermostat sends GET /temperature with Observe: 0 and Token 0xAB12. A Token is the client-chosen value that matches responses to a request. The server replies with the same Token, payload 23.5, Observe sequence 1, and Max-Age: 60. The Observe option in a successful response confirms registration; in responses its value orders updates.

Keep three decisions separate: the endpoint and Token bind the update to a request, the Observe sequence orders it, and Max-Age bounds how long its representation remains fresh. An acknowledgement confirms message receipt; the application must still decide whether to use the value. Cancellation ends the registration. Silence requires a stale-data and recovery rule.

Start With the Quiet Thermostat

The thermostat needs current temperature state, rather than a replay of every intermediate reading. Start with the registration above. If later notifications arrive out of order, retain the newer state. If its advertised freshness interval passes, mark the value stale and seek a fresh representation.

Observe does not promise that every change reaches the client. The following sections build the registration, ordering, pacing, and cleanup rules needed to make this decision.

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

An assumed energy model. At one poll per minute, polling creates 1,440 daily radio events, while Observe creates one registration plus 240 notifications, or 241 events. 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. This assumes one wake for each grouped exchange or notification. It excludes retries, idle energy, and other device work; byte savings alone cannot predict battery life. A 225 mAh, 3.0 V cell stores 2,430 J, so dividing by only these event costs gives about 563 versus 3,361 days. These are model outputs, not predicted service lives.

Math Bridge · guided foundationsWhy do event savings and byte savings disagree?Let Eddie connect radio wakes, joules, traffic, and an idealised cell life.
Chapter Roadmap
  • In 60 Seconds
  • Start With the Quiet Thermostat
  • Phoebe’s Field Notes: Why 89% Less Traffic Is Not 89% More Battery
  • Phoebe’s Field Notes: Count Radio Wakes, Not Only Bytes
  • Quick Check: Observe Fit
  • Prerequisites
  • Continue: CoAP Observe Registration and Freshness Contracts
  • The Observe Extension (RFC 7641)
  • Minimum Viable Understanding: CoAP Observe
  • CoAP Observe Subscriptions and Notifications
  • For Beginners: Understanding Observe vs Polling
  • Putting Numbers to It
  • Checkpoint: Push or Poll?
  • Interactive Calculator: Polling vs Observe Bandwidth
  • Observe Protocol Flow
  • Try It: Deregistration Method Advisor
  • Observer Management Implementation
  • Try It: Observer Registry Simulator
  • Putting Numbers to It
  • Interactive: CoAP Congestion Control
  • Interactive Calculator: Rate Limiting Configuration
  • Checkpoint: Registry Discipline
  • Deep Dive: Observe Internals
  • Deep Dive: Observe Sequence Numbers and Ordering
  • Interactive Tool: Sequence Number Freshness Checker
  • Deep Dive: Observer Removal Conditions
  • Try It: CON Retransmission Timeline Simulator
  • Edge Cases and Gotchas

Learning Objectives

Given a temperature trace, you will be able to:

  • Match a notification to its endpoint and Token, then decide which value is newer.
  • Distinguish stale representation data from a removed server registration.
  • Apply a pacing policy to a second sensor and explain its freshness limit.
  • Choose cancellation or recovery evidence after a restart or lost network path.
Quick Check: Observe Fit

Prerequisites

Before diving into this chapter, you should be familiar with:

Continue: CoAP Observe Registration and Freshness Contracts

The main chapter below stays focused on Observe as a server-push pattern and implementation workflow. For the deeper contract behind registration-token binding, Max-Age freshness, Confirmable liveness probes, notification ordering, wraparound, and stale-update handling, continue to CoAP Observe Registration and Freshness Contracts.

The Observe Extension (RFC 7641)

Minimum Viable Understanding: CoAP Observe

The worked thermostat uses a GET with Observe: 0. Registration succeeds only when the response includes Observe. Later responses retain the request Token and carry Observe values for ordering. This is direct resource observation; no broker is required.

A GET with Observe: 1 and the same Token cancels the observation. A Reset (RST) rejecting an unwanted notification also tells the server to remove its observer entry. Max-Age expiry instead means the saved representation needs refreshing.

Temperature Terry sends the thermostat’s current value after registration. Lila adds a second observer of the same resource. Each observer needs its own endpoint and Token state: removing Lila’s entry must not remove the thermostat’s entry.

Unlike an event archive, this stream represents current state. Several changes may be combined into a later notification. The client must recover current state after a gap instead of assuming it received every change.

Polling repeats a GET to ask for a current representation. Observe registers a continuing request so the server can send later representations. With infrequent changes, this can avoid many repeated requests.

Neither approach guarantees immediate detection. Polling waits for the next request; Observe depends on notification policy, network delivery, and recovery. Compare both against the same freshness requirement before choosing.

Traditional Polling vs. Observe

The energy question is not simply “push or poll”; it is how many exchanges occur when a resource changes less often than a client would ask for it. The timelines in Figure 1 show the exchanges generated when client requests outpace changes to a resource.

Read Figure 1 from left to right along each lane. Polling repeats a GET and response even when the value has not changed; Observe pays once to register, then the server emits notifications when the representation changes. The diagram explains the message-count difference, while the figures below quantify it for one assumed polling interval and change rate rather than claiming the same saving for every workload.

Traffic comparison for 24 hours of temperature monitoring:

  • Polling (every 60 seconds): 1,440 requests + 1,440 responses, about 61.9 KiB in the byte model below.
  • Observe (10 changes/hour): 1 registration request + 1 initial response + 240 notifications, about 6.6 KiB, about 89% fewer modelled bytes.

Assume a lossless exchange, 16-byte requests and 28-byte responses. Count only these message bytes; exclude UDP/IP, security, ACKs, retries, cancellation, and recovery. These sizes are example inputs, not fixed CoAP sizes. For polling every 60 seconds over 24 hours:

Polling requests=24×3,600 s60 s=1,440 requests\text{Polling requests} = \frac{24 \times 3{,}600 \text{ s}}{60 \text{ s}} = 1{,}440 \text{ requests}

With CoAP request (16 bytes) + response (28 bytes) = 44 bytes per exchange:

Poll Bandwidth=1,440×44=63,360 bytes≈61.9 KiB\text{Poll Bandwidth} = 1{,}440 \times 44 = 63{,}360 \text{ bytes} \approx 61.9 \text{ KiB}

For Observe with 10 changes/hour over 24 hours:

Observe Messages=2 (request and initial response)+(10×24)=242 messages\text{Observe Messages} = 2 \text{ (request and initial response)} + (10 \times 24) = 242 \text{ messages}

Observe Bandwidth=44+(240×28)=6,764 bytes≈6.6 KiB\text{Observe Bandwidth} = 44 + (240 \times 28) = 6{,}764 \text{ bytes} \approx 6.6 \text{ KiB}

The bandwidth reduction is:

Savings=63,360−6,76463,360≈0.893=89.3% reduction\text{Savings} = \frac{63{,}360 - 6{,}764}{63{,}360} \approx 0.893 = 89.3\% \text{ reduction}

Observer Architecture Overview

Before treating notifications as isolated responses, inspect the figure in the parent chapter to see the state that the client, wire exchange, and server must preserve together.

Start with one client. Track its own saved state. Read the architecture in the figure in the parent chapter from client state through Token and Observe ordering on the wire to the server’s observer registry. Then follow failure ownership and the bounded evidence required before the application accepts a notification. 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.

Bex guides the message review.Checkpoint: Push or Poll?

Predict the Observe message count if the initial response is counted separately. Does the byte saving prove a longer battery life?

Answer: There are 242 messages: two for registration and 240 later notifications. The model saves about 89.3% of the counted bytes, but excludes wake costs, retries and other energy use. Measure those before making a battery claim.

Interactive Calculator: Polling vs Observe Bandwidth

How to use: Compare polling interval and change rate under the same freshness requirement. The preserved calculator counts registration as one item in its Messages row, so add one for the initial response when counting individual messages. Its byte row includes both. Its recommendation uses byte savings alone; check loss, pacing, and energy separately.

Observe Protocol Flow

Registration

Continue the thermostat trace with illustrative arrival times measured from registration. The server endpoint is 192.0.2.10:5683; the thermostat endpoint is 192.0.2.20:61616. Observation A binds those endpoints and Token 0xAB12 to /temperature with Accept: text/plain. Observation B uses the same endpoints and resource but Token 0xCD34 with Accept: application/json; it remains a separate registration throughout this trace. A representation is the resource value encoded in the response payload. Accept: text/plain asks for a plain-text representation. The client requests registration as follows:

Request

  • Client -> Server: GET /temperature
  • Token: 0xAB12
  • Observe: 0 (register)
  • Accept: text/plain

Response

  • Server -> Client: 2.05 Content
  • Token: 0xAB12
  • Observe: 1 (sequence number)
  • Max-Age: 60
  • Payload: "23.5"

Observation A receives this response at t=0 s. The response includes Observe, so registration succeeded. Display 23.5°C until a newer representation is accepted; without one, mark it stale at t=60 s (0 + 60). Max-Age does not give the server a 60-second observer lease. Observation B receives its own successful registration response with Token 0xCD34 at t=0 s; responses for B never update A.

Notifications

Inspect the figure in the parent chapter to see how a client proves that each notification belongs to its observation and is fresher than the value already accepted.

Continue observation A with the arrivals in the table. The figure follows a subscription from registration through updates, cancellation or loss, and re-registration. For each arrival, first check that it came from the bound server endpoint to the bound thermostat endpoint with Token 0xAB12. Then compare its Observe value with the latest accepted response. All sequence comparisons occur within 128 seconds of the latest accepted response. A newer notification may update the value, but its Max-Age sets a freshness limit. A received notification still needs application acceptance checks. Times are local receipt times. The table records the receipt times, sequence values, temperatures, freshness limits, and decisions for A.

With no further accepted response, mark A’s 23.0°C stale at t=50 s and seek fresh state. The rejected arrival does not move the deadline to t=115 s (25 + 90). At t=55 s, the server receives A’s cancellation GET for /temperature with Observe: 1, Token 0xAB12, and the same endpoint binding. Remove only A’s registry entry; B with Token 0xCD34 remains. Expiry at 50 seconds did not itself remove either entry.

Watch one subscription from start to end. Track its state. Trace the figure in the parent chapter from registration through successive notifications. 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. Cancellation or relationship loss ends that state, and re-registration requires reconciliation. That lifecycle frames the sequence-number knowledge check next.

Deregistration

In the worked trace, the explicit request below is sent from 192.0.2.20:61616 to 192.0.2.10:5683 and received at t=55 s. It removes observation A (0xAB12) while B (0xCD34) remains. More generally, cancel the thermostat observation explicitly, reject an unwanted notification, or let the server detect failed delivery. A lost client cannot promise that the server immediately stops sending.

1. Explicit deregistration (GET with Observe: 1):

  • Client -> Server: GET /temperature
  • Token: 0xAB12
  • Observe: 1 (deregister)

2. RST response to unwanted notification:

  • Server -> Client: NON 2.05 Content (notification)
  • Client -> Server: RST (stop this observation)

3. Failed delivery or an application lease:

A Confirmable (CON) notification requests an acknowledgement (ACK) and can be retransmitted. A Non-confirmable (NON) notification has no such ACK exchange. Failed CON delivery can trigger observer removal; a server may separately implement a renewable application lease. Max-Age expiry alone does not remove an observer. Match a RST to the notification Message ID, then remove the associated observation.

Try It: Deregistration Method Advisor

How to use: Select a scenario to see the recommended deregistration method, the protocol exchange, and the energy cost. Toggle between CON and NON to see how notification reliability affects cleanup behavior.

The protocol flow gives the client-side contract: register with Observe: 0, accept ordered notifications, and leave cleanly with Observe: 1 or RST. The next layer is the server-side contract that remembers each observer without letting stale entries accumulate.

Observer Management Implementation

Server-Side Observer Registry

The registry below retains the thermostat endpoint, Token, resource, and representation-selecting GET options. Its 24-hour timeout is an example application lease. Cleanup occurs when notify_all runs; a quiet resource needs a separate cleanup scheduler. The send and representation-selection methods are placeholders, so this is a registry sketch rather than an executable CoAP server.

from collections import defaultdict
from dataclasses import dataclass
import time

@dataclass
class Observer:
    client_addr: object
    token: bytes
    request_options: dict  # Effective GET options that select/cache the representation.
    registered_at: float
    last_notification: float
    timeout: float

class ObserverRegistry:
    def __init__(self):
        # Map: resource_uri -> list of Observer objects
        self.observers = defaultdict(list)
        self.observer_timeout = 86400  # 24 hours default

    def register_observer(self, resource_uri, client_addr, token, request_options,
                          lease_seconds=None):
        # Include effective Accept and other representation-selecting GET options.
        options_snapshot = dict(request_options)
        # RFC 7641 §4.1: refresh an existing endpoint/token pair, do not append it twice.
        for existing in self.observers[resource_uri]:
            if existing.client_addr == client_addr and existing.token == token:
                existing.registered_at = time.time()
                existing.timeout = lease_seconds or self.observer_timeout
                existing.request_options = options_snapshot
                return existing
        observer = Observer(
            client_addr=client_addr,
            token=token,
            request_options=options_snapshot,
            registered_at=time.time(),
            last_notification=time.time(),
            timeout=lease_seconds or self.observer_timeout  # application policy, not Max-Age
        )
        self.observers[resource_uri].append(observer)
        return observer

    def notify_all(self, resource_uri):
        """Send notification to all observers of a resource"""
        expired = []

        for observer in self.observers[resource_uri]:
            # Check if observation expired
            if time.time() - observer.registered_at > observer.timeout:
                expired.append(observer)
                continue

            # Re-evaluate this observer's selected representation using its GET options.
            value, content_format = self.select_representation(
                resource_uri, observer.request_options
            )
            self.send_notification(observer, value, content_format)

        # Clean up expired observers
        for observer in expired:
            self.observers[resource_uri].remove(observer)

    def remove_observer(self, resource_uri, client_addr, token):
        """Remove observer on explicit deregistration or RST received"""
        self.observers[resource_uri] = [
            o for o in self.observers[resource_uri]
            if not (o.client_addr == client_addr and o.token == token)
        ]

Knowledge check · self-test

Knowledge check

Test your understanding.

Try It: Observer Registry Simulator

This widget previews an operation against a fixed sample registry. It does not persist additions or removals, and its client-ID key omits the endpoint/Token distinction used in the Python sketch. Compare its predicted counts; use an actual server trace to verify state changes. The one-hour age cutoff is an application policy, not Max-Age.

Notification Rate Limiting

Transfer the thermostat rule to the boiler example below. A change threshold is the minimum difference from the last sent value; a minimum interval limits routine send frequency. The example also has a separate urgent crossing path. These are application policies, not built-in Observe guarantees.

This callback checks only when a new value arrives. It has no timer to send a deferred value or refresh an unchanged representation. A complete implementation must schedule those actions and key per-observer state by endpoint and Token; this sketch keys only by Token.

class RateLimitedResource:
    def __init__(self, min_interval=1.0, change_threshold=0.5,
                 urgent_alarm_threshold=None):
        self.min_interval = min_interval    # Minimum seconds between notifications
        self.change_threshold = change_threshold  # Minimum change to trigger notification
        self.urgent_alarm_threshold = urgent_alarm_threshold
        self.last_notify_time = {}          # Per-observer last notification time
        self.last_notified_value = {}       # Per-observer last sent value

    def on_value_change(self, new_value):
        now = time.time()

        for observer in self.observers:
            last_time = self.last_notify_time.get(observer.token, 0)
            last_value = self.last_notified_value.get(observer.token, None)

            # Routine readings obey both gates; an alarm crossing bypasses the time gate.
            routine_notify = (
                last_value is None or
                (abs(new_value - last_value) >= self.change_threshold and
                 (now - last_time) >= self.min_interval)
            )
            urgent_alarm = (
                self.urgent_alarm_threshold is not None and
                new_value >= self.urgent_alarm_threshold and
                (last_value is None or last_value < self.urgent_alarm_threshold)
            )

            if routine_notify or urgent_alarm:
                self.send_notification(observer, new_value)
                self.last_notify_time[observer.token] = now
                self.last_notified_value[observer.token] = new_value

The rate limiting logic above combines two thresholds to prevent notification storms. For a sensor with value v(t)v(t) at time tt, a notification is sent when:

notify=∣Δv∣≥θv AND Δt≥θt\text{notify} = |\Delta v| \geq \theta_v \text{ AND } \Delta t \geq \theta_t

where Δv=vnew−vlast\Delta v = v_{\text{new}} - v_{\text{last}} is the value change and Δt=tnow−tlast\Delta t = t_{\text{now}} - t_{\text{last}} is time since last notification.

For example, a temperature sensor monitoring a boiler room:

  • Change threshold: θv=0.5°C\theta_v = 0.5°\text{C}
  • Time threshold: θt=60s\theta_t = 60\text{s}

If a routine reading jumps from 80°C to 82°C in 10 seconds: ∣Δv∣=∣82−80∣=2°C≥0.5°C⇒no routine send at this callback|\Delta v| = |82 - 80| = 2°\text{C} \geq 0.5°\text{C} \Rightarrow \text{no routine send at this callback}

If the example application configures 82°C as an urgent alarm threshold (not a recommended safety limit), crossing it sends an immediate alarm notification even inside that 60-second interval. Alarm handling is a separate path; routine updates retain the cap.

If temperature drifts slowly from 80.0°C to 80.3°C over 65 seconds: ∣Δv∣=0.3°C<0.5°C AND Δt=65s≥60s⇒do not notify yet|\Delta v| = 0.3°\text{C} < 0.5°\text{C} \text{ AND } \Delta t = 65\text{s} \geq 60\text{s} \Rightarrow \text{do not notify yet}

This dual-threshold policy caps the notification rate and ignores small changes. To bound staleness, schedule a separate refresh before the advertised Max-Age expires.

A CoAP server has 100 clients observing a temperature resource that changes 10 times per second. It currently notifies every client on every change without pacing, and its measured delivery capacity is below 1,000 notifications per second. What problem should the team fix first?

Notification flood - add rate limits and change thresholds

Correct. Rate limits or change thresholds reduce unnecessary notifications below the measured capacity, while the design must still meet its freshness contract.

A CoAP server has 20 observers and a resource changes twice a second. It sends one notification per observer per change; measured capacity is 1,000 notifications a second. What does this load check show?

The 40 notifications per second are below measured capacity.

Correct. The calculated rate does not itself show the original notification flood.

Interactive: CoAP Congestion Control

Simulation · interactive

CoAP Congestion Control Workbench

Explore how the system behaves.

Interactive Calculator: Rate Limiting Configuration

How to use: Configure your sensor’s update rate and desired notification thresholds. The calculator estimates a rate ceiling under a steady monotonic change assumption; discrete readings and the value path determine actual sends. Urgent alarms use a separate path.

Bex guides the message review.Checkpoint: Registry Discipline

The boiler last sent 80°C, rises to 82°C after 10 seconds, and uses a 0.5°C change threshold with a 60-second minimum interval. Predict the routine send. Does silence delete its observers?

Answer: The value gate passes but the time gate fails, so this callback sends no routine notification. A separately configured urgent crossing can send. Max-Age expiry makes client data stale; it does not delete the server entries. Schedule refresh and cleanup separately.

Deep Dive: Observe Internals

The thermostat accepts sequence 47, then receives sequence 46 with the same endpoint and Token one second later. How should it use the Observe value?

Use it to reject 46 as older than the accepted 47

Correct! The Observe option value in server responses and notifications is a 24-bit sequence number (0 to 16,777,215). The client compares it with later notifications using RFC 7641 Section 3.4 serial arithmetic; after more than 128 seconds, arrival time can make a notification newer.

An unseen trace has observations C (Token 0x10) and D (Token 0x20), both from client 192.0.2.30:61616 to server 192.0.2.10:5683 for /temperature. C accepts Observe=200, 19.0°C, Max-Age=40 at t=5 s; then receives 202, 20.0°C, Max-Age=20 at t=15 s and 201, 19.5°C, Max-Age=90 at t=18 s. No other responses arrive. At t=40 s the server receives a cancellation GET with Observe=1 and Token 0x20 from that client endpoint. Which result is correct?

C retains 20.0°C, becomes stale at t=35 s, and cancellation removes D only.

Correct. 202 advances from 200, so C accepts 20.0°C and sets its deadline to 15 + 20 = 35 seconds. The older 201 arrives only 3 seconds later and is rejected; its Max-Age cannot renew the accepted value. Token 0x20 at the bound endpoint identifies D for cancellation.

Deep Dive: Observe Sequence Numbers and Ordering

The Observe option value is a sequence number that helps clients detect:

  1. Out-of-order notifications (UDP doesn’t guarantee ordering)
  2. Notification freshness (which update is newer)

Client Ordering Rules (RFC 7641 Section 3.4):

def is_notification_fresh(current_seq, new_seq, elapsed_seconds=0):
    """
    Determine if new notification is fresher than current.
    Handles 24-bit wraparound.
    """
    # Sequence numbers are 24-bit (0 to 16,777,215)
    MAX_SEQ = (1 << 24) - 1

    # Calculate difference handling wraparound
    diff = (new_seq - current_seq) % (MAX_SEQ + 1)

    # Within 128 s, use the serial half-range (positive diff below 2^23).
    # After 128 s, accept by arrival time even if the sequence goes backward.
    return elapsed_seconds > 128 or 0 < diff < (1 << 23)

Apply the rule to observation A in the worked trace: sequence 100 arrives at t=10 s with Max-Age 40; 102 at t=20 s with Max-Age 30; and 101 at t=25 s with Max-Age 90. All responses match A’s endpoint binding and Token 0xAB12. The protected sequence illustration below shows the same values. Accepting 102 sets the stale deadline to t=50 s; rejecting 101 leaves that deadline unchanged.

Example scenario:

Notification 1: Observe=100, temp=22.5
Notification 2: Observe=102, temp=23.0  (arrived out of order)
Notification 3: Observe=101, temp=22.8

Client receives: 100 -> 102 -> 101
Client should display: 22.5 -> 23.0 (ignore 101, it's older than 102)
Interactive Tool: Sequence Number Freshness Checker

How to use: Enter current and new sequence numbers to see if the notification should be accepted or discarded. This tool applies the RFC 7641 Section 3.4 sequence comparison and arrival-time rule: an incoming notification is newer if its sequence advances within the half-range, or if more than 128 seconds have passed since the freshest accepted notification.

Automatic observer removal triggers:

  1. RST received: Client sends RST in response to notification
  2. Application lease: No renewal within a configured server-side lease
  3. CON notification fails: After 4 retransmissions without ACK
  4. Resource deleted: Server removes all observers when resource gone

Retransmission behavior for CON notifications:

Server sends CON notification
Wait 2–3 seconds for ACK (RFC default randomization)
Retransmit with same Message ID
Wait 4–6 seconds (exponential backoff)
Retransmit
Wait 8–12 seconds
Retransmit
Wait 16–24 seconds
Final retransmission
Wait 32–48 seconds for ACK; if none arrives, remove observer
Try It: CON Retransmission Timeline Simulator

How to use: This is a timing model, not a packet trace. The preserved ACK selector is offset: selecting 1 marks Retry 1, while the original send cannot be selected; read the Result row to see the modelled ACK. Adjust the timeout parameters and backoff multiplier to see how the retransmission timeline changes. Set “ACK arrives after attempt #” to simulate scenarios where the client eventually responds. With an initial 2-second timeout and four retransmissions, it takes 62 seconds to finish the last ACK wait; RFC default randomization can extend that to 93 seconds.

Deep internals explain why the same notification stream can survive UDP reordering and unreachable clients. Now apply those mechanics to deployment failures, where restarts, NAT mappings, and stale tokens are the usual reasons Observe looks unreliable.

Edge Cases and Gotchas

Token Reuse After Client Restart

Problem:

- Client registers observation with Token=0x42
- Client crashes and restarts
- Server sends notification with Token=0x42
- Client doesn't recognize token (state lost) -> sends RST
- Server removes observer

Solutions:

  1. Server MUST remove observer when RST received
  2. Client should re-register observations after restart
  3. If persisting observation state, reconcile it with the server and current representation after restart before trusting it

NAT Timeout Issue

Problem:

UDP NAT mapping lifetime varies by network; this example assumes 45 seconds
- Client behind NAT registers observation
- Server tries to push notification 5 minutes later
- NAT mapping expired -> notification never reaches client

Solutions:

  1. Client sends periodic traffic before its measured NAT mapping expires
  2. Client sends periodic re-registration (GET with Observe=0)
  3. Use Max-Age to bound representation freshness; plan notifications or re-registration accordingly
  4. Evaluate a supported CoAP-over-TCP deployment separately; changing transport does not remove the need for liveness and freshness rules

Transfer prediction: A boiler display has a 60-second Max-Age and receives nothing for five minutes. Must the server have deleted it?

Answer: No. The displayed value is stale, but silence does not reveal server registry state. Check the network path, re-register for fresh state, and reconcile the response before displaying it as current.

Continue to the Next Part

Carry this evidence into CoAP Observe: Efficiency and Lifecycle, which begins with Interactive Calculator: NAT Keep-Alive Interval.

Detail notes moved from the chapter

Historical protected source blocks retained for the chapter preservation check.

Two timelines compare repeated GET/response pairs with registration and later state notifications. Use the lanes to separate registration cost from recurring traffic.
Polling repeats request/response exchanges; Observe registers once and sends later state notifications. Compare both lanes before counting traffic.
Client, wire, and server panels separate observation state from notification checks. Follow identity, ordering, and failure ownership before accepting a value.
Follow client state through endpoint/Token identity to the server registry. Ordering and freshness checks determine whether the application can use an update.
The lifecycle follows registration, updates, cancellation or loss, and re-registration. Token continuity, ordering, and freshness checks explain when a value can be used.
Follow registration through ordered updates, cancellation, and recovery. A received notification still needs application acceptance checks.

Hi, I’m Broker Bex. What do you need?

Find help

Let’s find what you need

Find a lesson or return to your module guide.

Give feedback

Help improve this chapter

Tell us what helped or what needs fixing.

Tips

Try a small next step

A few ways to get more from this chapter.

Ask AI

Continue the conversation

Take the conversation further with your preferred assistant.

AI help is available in supported modules when enabled in Settings.

No live person answers on independent study. Feedback does not promise a personal reply.

For welfare or safety concerns, follow your school’s procedures outside IoTClass.