Skip to content
SIP Mastery

Part 8 · Call flow library / Module 23

Events, presence, and messaging

SIP beyond calls: SUBSCRIBE and NOTIFY with Event, Subscription-State, and Expires; the event packages that phones use every day (presence, dialog for busy lamps, message-summary for voicemail, reg, and refer); PUBLISH and presence servers; and instant messages with MESSAGE.

IntermediateNOC coreDEV core

After this module, you can

  • Follow a subscription from SUBSCRIBE to the last NOTIFY, and read Event, Subscription-State, and Expires in each message.
  • Name the common event packages, what each one reports, and its body format.
  • Explain how PUBLISH and entity-tags keep a presence server up to date, and what a 412 means.
  • Send an instant message with MESSAGE, and tell a 200 from a 202.
  • Recognise a subscription that expires, a NOTIFY rejected too early, and a MESSAGE too big for UDP.
On this page6 sections
  1. 23.1SUBSCRIBE and NOTIFY: Event, Subscription-State, Expires
  2. 23.2Event packages: presence, dialog (BLF), message-summary (MWI), reg, refer
  3. 23.3PUBLISH and presence servers
  4. 23.4MESSAGE (page-mode instant messages)
  5. Common mistakes
  6. Summary

23.1 SUBSCRIBE and NOTIFY: Event, Subscription-State, Expires

A call is not the only thing SIP can tell you about. A phone can ask to be told when something changes: whether a colleague is on the phone, whether new voicemail has arrived, whether its own registration is still valid. RFC 6665 defines the mechanism, with two methods:

RFC 6665 §1.1 · Overview of Operation
“The general concept is that entities in the network can subscribe to resource or call state for various resources or calls in the network, and those entities (or entities acting on their behalf) can send notifications when those states change.”
Read the section ↗
  • The subscribersubscriber. The user agent that sends SUBSCRIBE and receives NOTIFY. sends SUBSCRIBE, with an Event header that names the event packageevent package. A named use of SUBSCRIBE and NOTIFY, such as presence or dialog, given in the Event header. It defines the body format and when to notify., and Expires, the time it wants the subscriptionsubscription. A request, made with SUBSCRIBE (or implied by REFER), to get NOTIFY requests when the state of a resource changes. It lasts for the time in Expires, unless the subscriber refreshes it. to last.
  • The notifiernotifier. The user agent that accepts a SUBSCRIBE and sends NOTIFY requests with the state of the resource. answers 200 OK, with the Expires it grants, and at once sends a NOTIFY with the full current state. More NOTIFYs follow each time the state changes.
  • Each NOTIFY carries Subscription-State: active, pending, or terminated, with the time left in expires, or the reason it ended.
  • SUBSCRIBE creates a dialog, like INVITE. Refreshes, the unsubscribe, and every NOTIFY travel inside it.

Flow builder · a subscription from start to end

Message waiting: Alice unsubscribes

  • SIP
Package
Notifier
End
What if

Alice192.0.2.10Voicemail server203.0.113.5001SUBSCRIBE02200 OK03NOTIFY (active)04200 OK (NOTIFY)05NOTIFY (active)06200 OK (NOTIFY)07SUBSCRIBE (refresh)08200 OK09NOTIFY (active)10200 OK (NOTIFY)11SUBSCRIBE (Expires: 0)12200 OK13NOTIFY (terminated)14200 OK (NOTIFY)
01/14

Alice's phone subscribes to her own mailbox. Event names the package; Expires asks for an hour.

All steps as text
  1. Alice → Voicemail server: SUBSCRIBE. Alice's phone subscribes to her own mailbox. Event names the package; Expires asks for an hour.
  2. Voicemail server → Alice: 200 OK. The notifier accepts the subscription. The 200 OK must carry Expires: the duration that counts.
  3. Voicemail server → Alice: NOTIFY (active). The first NOTIFY follows at once, with the full current state.
  4. Alice → Voicemail server: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  5. Voicemail server → Alice: NOTIFY (active). Bob leaves Alice a voicemail. Messages-Waiting: yes turns on her message lamp.
  6. Alice → Voicemail server: 200 OK (NOTIFY). Alice's phone confirms, and shows the new state.
  7. Alice → Voicemail server: SUBSCRIBE (refresh). Before the hour ends, Alice's phone refreshes the subscription in the same dialog, with the next CSeq.
  8. Voicemail server → Alice: 200 OK. The notifier extends the subscription by another hour.
  9. Voicemail server → Alice: NOTIFY (active). Each refresh also brings a NOTIFY with the full state.
  10. Alice → Voicemail server: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  11. Alice → Voicemail server: SUBSCRIBE (Expires: 0). Alice's phone unsubscribes: a SUBSCRIBE in the same dialog with Expires: 0.
  12. Voicemail server → Alice: 200 OK. The notifier accepts. The subscription now ends.
  13. Voicemail server → Alice: NOTIFY (terminated). A final NOTIFY says terminated, with the state one last time.
  14. Alice → Voicemail server: 200 OK (NOTIFY). Alice's phone confirms. The subscription is over.
RFC 6665 §3.1.1 · Subscription Duration
“200-class responses to SUBSCRIBE requests also MUST contain an "Expires" header field. The period of time in the response MAY be shorter but MUST NOT be longer than specified in the request.”
Read the section ↗
RFC 6665 §4.2.1.2 · Confirmation of Subscription Creation/Refreshing
“Upon successfully accepting or refreshing a subscription, notifiers MUST send a NOTIFY request immediately to communicate the current resource state to the subscriber.”
Read the section ↗

A subscription is soft state, like a registration: it disappears unless the subscriber refreshes it with another SUBSCRIBE in the same dialog. To end it early, the subscriber sends SUBSCRIBE with Expires: 0, and the notifier answers with a last NOTIFY that says terminated. Try End in the builder:

Subscription-State Meaning What the subscriber does
active;expires=3600 Accepted; 3600 s left Refresh before the time runs out
pending Received, not yet authorised Wait for the next NOTIFY
terminated;reason=timeout Not refreshed in time Subscribe again, with a new dialog
terminated;reason=deactivated The notifier is moving or restarting Subscribe again at once
terminated;reason=rejected No longer authorised Do not subscribe again
terminated;reason=noresource The resource no longer exists Do not subscribe again
RFC 6665 §4.1.3 · Receiving and Processing State Information
“timeout: The subscription has been terminated because it was not refreshed before it expired. Clients MAY re-subscribe immediately.”
Read the section ↗

One rule surprises many implementers. The first NOTIFY can arrive before the 200 OK to the SUBSCRIBE: the 200 OK can be lost or delayed on the way, and the NOTIFY overtakes it. Turn on NOTIFY before the 200 OK:

RFC 6665 §4.1.2.4 · Confirmation of Subscription Creation
“Due to the potential for out-of-order messages, packet loss, and forking, the subscriber MUST be prepared to receive NOTIFY requests before the SUBSCRIBE transaction has completed.”
Read the section ↗

23.2 Event packages: presence, dialog (BLF), message-summary (MWI), reg, refer

Each event package defines what its NOTIFY bodies contain and when the notifier sends them. These five cover most real deployments:

Event What it reports Body Typical use
presence Whether a person is available application/pidf+xml (PIDFPIDF. Presence Information Data Format (RFC 3863), the XML document that carries presence: a tuple with a basic status of open or closed.) Buddy lists in softphones and UC clients
dialog The calls of a user: trying, early, confirmed, terminated application/dialog-info+xml busy lamp fieldbusy lamp field. The lamps on a phone that show whether colleagues are idle, ringing, or busy, usually through the dialog event package. keys, call pickup (Module 22)
message-summary New and old voicemail application/simple-message-summary The message waiting indicatormessage waiting indicator. The lamp or icon on a phone that shows new voicemail, through the message-summary event package. lamp
reg The bindings of an AOR application/reginfo+xml IMS phones learn when the network ends their registration
refer The progress of a REFER message/sipfrag Call transfer (Module 22); the REFER itself creates the subscription

Change Package in the builder to see each one. The dialog package drives the busy lamps on a receptionist’s phone:

Flow builder · a busy lamp for Bob

Dialog (busy lamp): Alice unsubscribes

  • SIP
Package
Notifier
End
What if

Alice192.0.2.10PBX203.0.113.501SUBSCRIBE02200 OK03NOTIFY (active)04200 OK (NOTIFY)05NOTIFY (active)06200 OK (NOTIFY)07SUBSCRIBE (Expires: 0)08200 OK09NOTIFY (terminated)10200 OK (NOTIFY)
01/10

Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.

All steps as text
  1. Alice → PBX: SUBSCRIBE. Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.
  2. PBX → Alice: 200 OK. The notifier accepts the subscription. The 200 OK must carry Expires: the duration that counts.
  3. PBX → Alice: NOTIFY (active). The first NOTIFY follows at once, with the full current state.
  4. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  5. PBX → Alice: NOTIFY (active). Bob answers a call. The PBX reports a confirmed dialog, so Alice's busy lamp for Bob turns red.
  6. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms, and shows the new state.
  7. Alice → PBX: SUBSCRIBE (Expires: 0). Alice's phone unsubscribes: a SUBSCRIBE in the same dialog with Expires: 0.
  8. PBX → Alice: 200 OK. The notifier accepts. The subscription now ends.
  9. PBX → Alice: NOTIFY (terminated). A final NOTIFY says terminated, with the state one last time.
  10. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms. The subscription is over.
RFC 4235 §3.7 · Notifier Generation of NOTIFY Requests
“Notifications are generated for the dialog package when an INVITE request is sent, when a new dialog comes into existence at a UA, or when the state or characteristics of an existing dialog changes.”
Read the section ↗

The message-summary body is plain text, so even a phone with no display can read it:

RFC 3842 §3.5 · NOTIFY Bodies
“The text format begins with a simple status line, and optionally a summary line per message-context-class.”
Read the section ↗

The reg package lets a phone learn that the network has shortened or ended its registration, for example to force it to authenticate again:

RFC 3680 §3.1 · Forcing Re-Authentication
“To do this, the device subscribes to the registration event package for the address-of-record that it is registering contacts against.”
Read the section ↗

A notifier that does not know the package answers 489 Bad Event. A UA lists the packages it supports in Allow-Events. Some voicemail systems send message-summary NOTIFYs with no SUBSCRIBE at all (“unsolicited NOTIFY”). Many phones accept them, but RFC 6665 does not define them; a SUBSCRIBE is the standard way.

23.3 PUBLISH and presence servers

Presence has three roles. The presentitypresentity. The person or resource whose presence others watch. In Module 23, Bob. (Bob) has a state; watcherswatcher. A subscriber to the presence of a presentity. In Module 23, Alice. (Alice) subscribe to it; the Presence serverPresence server. The server that collects presence state with PUBLISH and sends it to watchers with NOTIFY. sits between them. Bob’s phone does not answer every watcher itself. It publishes its state to the presence server, and the server notifies the watchers (RFC 3903):

RFC 3856 §6.5 · NOTIFY Bodies
“In this event package, the body of the notification contains a presence document. This document describes the presence of the presentity that was subscribed to.”
Read the section ↗

Call flow · one publication: create, refresh, modify, remove

PUBLISH: create, refresh, modify, remove

  • SIP
Bob203.0.113.20Presence server203.0.113.1501PUBLISH (initial)02200 OK03PUBLISH (refresh)04200 OK05PUBLISH (modify)06200 OK07PUBLISH (remove)08200 OK
01/08

Bob's phone publishes his presence. An initial PUBLISH has a body and no SIP-If-Match.

All steps as text
  1. Bob → Presence server: PUBLISH (initial). Bob's phone publishes his presence. An initial PUBLISH has a body and no SIP-If-Match.
  2. Presence server → Bob: 200 OK. The presence server stores the state for an hour. SIP-ETag names it.
  3. Bob → Presence server: PUBLISH (refresh). Before the hour ends, Bob's phone refreshes. A refresh has SIP-If-Match and no body.
  4. Presence server → Bob: 200 OK. The server extends the state, and gives it a new entity-tag. The phone must use the new one next time.
  5. Bob → Presence server: PUBLISH (modify). Bob starts a call. His phone sends the new state, with SIP-If-Match and a body.
  6. Presence server → Bob: 200 OK. The server replaces the state and notifies every watcher of Bob.
  7. Bob → Presence server: PUBLISH (remove). Bob logs out. Expires: 0 removes the published state.
  8. Presence server → Bob: 200 OK. The server removes the state. Watchers now see what the server composes without it.

A publication is soft state too. The server names it with an entity-tagentity-tag. The name that a presence server gives to published state, in SIP-ETag. A later PUBLISH names the state it refreshes or changes in SIP-If-Match., returned in SIP-ETag. Every later PUBLISH names the state it acts on in SIP-If-Match:

PUBLISH SIP-If-Match Body Effect
Initial None The full state Creates new state, and a new entity-tag
Refresh The current entity-tag None Extends the lifetime, and changes the entity-tag
Modify The current entity-tag The new state Replaces the state
Remove The current entity-tag None, with Expires: 0 Deletes the state
RFC 3903 §4.4 · Modifying Event State
“To modify event state, the EPA MUST construct a PUBLISH request that includes in a SIP-If-Match header field the entity-tag of the event state publication to be modified.”
Read the section ↗

The presence server does more than relay: it composes state from several publishers (Bob’s desk phone, his mobile, his calendar), and it applies Bob’s authorisation rules. A watcher that Bob has not yet allowed gets pending until he decides:

Flow builder · presence, with a pending watcher

Presence: Alice unsubscribes

  • SIP
Package
Notifier
End
What if

Alice192.0.2.10Presence server203.0.113.15Bob203.0.113.2001PUBLISH02200 OK03SUBSCRIBE04200 OK05NOTIFY (pending)06200 OK (NOTIFY)07NOTIFY (active)08200 OK (NOTIFY)09PUBLISH10200 OK11NOTIFY (active)12200 OK (NOTIFY)13SUBSCRIBE (Expires: 0)14200 OK15NOTIFY (terminated)16200 OK (NOTIFY)
01/16

Bob's phone publishes his presence to the presence server: a PIDF document, with no SIP-If-Match.

All steps as text
  1. Bob → Presence server: PUBLISH. Bob's phone publishes his presence to the presence server: a PIDF document, with no SIP-If-Match.
  2. Presence server → Bob: 200 OK. The server stores the state. SIP-ETag names it, for later changes.
  3. Alice → Presence server: SUBSCRIBE. Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.
  4. Presence server → Alice: 200 OK. The notifier accepts the subscription. The 200 OK must carry Expires: the duration that counts.
  5. Presence server → Alice: NOTIFY (pending). Bob has not yet said whether Alice may watch him. The NOTIFY says pending, with no state.
  6. Alice → Presence server: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  7. Presence server → Alice: NOTIFY (active). Bob allows Alice to watch him. The next NOTIFY says active, with his current state.
  8. Alice → Presence server: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  9. Bob → Presence server: PUBLISH. Bob's phone publishes the change. SIP-If-Match names the state it replaces.
  10. Presence server → Bob: 200 OK. The server replaces state dx200xyz. The new SIP-ETag is kwj449x.
  11. Presence server → Alice: NOTIFY (active). Bob starts a call. The presence server has his new state from his PUBLISH.
  12. Alice → Presence server: 200 OK (NOTIFY). Alice's phone confirms, and shows the new state.
  13. Alice → Presence server: SUBSCRIBE (Expires: 0). Alice's phone unsubscribes: a SUBSCRIBE in the same dialog with Expires: 0.
  14. Presence server → Alice: 200 OK. The notifier accepts. The subscription now ends.
  15. Presence server → Alice: NOTIFY (terminated). A final NOTIFY says terminated, with the state one last time.
  16. Alice → Presence server: 200 OK (NOTIFY). Alice's phone confirms. The subscription is over.
RFC 6665 §4.1.3 · Receiving and Processing State Information
“If the "Subscription-State" value is "pending", the subscription has been received by the notifier, but there is insufficient policy information to grant or deny the subscription yet.”
Read the section ↗

23.4 MESSAGE (page-mode instant messages)

MESSAGE (RFC 3428) carries an instant message in its body, usually text/plain. Each message is a separate transaction, routed like any other request; there is no dialog and no session. This is “page mode”: like a pager, one message at a time.

RFC 3428 §4 · UAC Processing
“MESSAGE requests do not initiate dialogs. User Agents MUST NOT insert Contact header fields into MESSAGE requests.”
Read the section ↗

Call flow · an instant message and a reply

MESSAGE: an instant message and a reply

  • SIP
Alice192.0.2.10Proxy B203.0.113.10Bob203.0.113.2001MESSAGE02MESSAGE03200 OK04200 OK05MESSAGE06200 OK
01/06

Alice sends Bob an instant message. A MESSAGE has a text/plain body, and no Contact: it makes no dialog.

All steps as text
  1. Alice → Proxy B: MESSAGE. Alice sends Bob an instant message. A MESSAGE has a text/plain body, and no Contact: it makes no dialog.
  2. Proxy B → Bob: MESSAGE. Proxy B finds Bob's Contact and forwards the MESSAGE, like any request.
  3. Bob → Proxy B: 200 OK. Bob's phone shows the message and answers 200 OK.
  4. Proxy B → Alice: 200 OK. Alice's phone knows that the message arrived, not that Bob has read it.
  5. Bob → Alice: MESSAGE. Bob replies. The reply is a new request, with a new Call-ID: there is no conversation in SIP itself.
  6. Alice → Bob: 200 OK. Alice's phone confirms.

The response says how far the message got. A 200 OK means that the recipient’s UA has it, not that a person has read it. A 202 Accepted means that a store-and-forward server has it and will try to deliver it later:

RFC 3428 §4 · UAC Processing
“If the UAC receives a 202 Accepted response, the message has been delivered to a gateway, store and forward server, or some other service that may eventually deliver the message.”
Read the section ↗

Call flow · stored by the IM service, delivered later

MESSAGE: stored and forwarded later

  • SIP
Alice192.0.2.10Proxy B203.0.113.10Bob203.0.113.2001MESSAGE02202 Accepted03MESSAGE04200 OK
01/04

Alice sends Bob a message while his phone is off.

All steps as text
  1. Alice → Proxy B: MESSAGE. Alice sends Bob a message while his phone is off.
  2. Proxy B → Alice: 202 Accepted. Proxy B's IM service stores the message. 202 means: accepted for later delivery, not delivered.
  3. Proxy B → Bob: MESSAGE. Later, Bob's phone registers again. The IM service sends the stored message, as a new request of its own.
  4. Bob → Proxy B: 200 OK. Bob's phone shows the message. Alice is not told: a 202 gives no delivery report.

MESSAGE is for short texts. A longer conversation, file transfer, or anything over 1300 bytes belongs in a session: an INVITE that sets up an MSRP media stream (RFC 4975), which carries messages over TCP. Delivery and read reports for MESSAGE need another extension, IMDN (RFC 5438).

RFC 3428 §8 · Congestion Control
“The size of MESSAGE requests outside of a media session MUST NOT exceed 1300 bytes, unless the UAC has positive knowledge that the message will not traverse a congestion-unsafe link at any hop, or that the message size is at least 200 bytes less than the lowest MTU value found en route to the UAS.”
Read the section ↗

Common mistakes

Busy lamps that go dark after an hour

A receptionist’s phone subscribes to the dialog state of thirty colleagues, with Expires: 3600, and never refreshes. Everything works after a reboot. An hour later, each subscription ends with reason=timeout, and the lamps stay off: the receptionist transfers calls to people who are already on the phone.

Broken: never refreshes

Dialog (busy lamp): the subscription times out

  • SIP
  • ⚠Problem
Alice192.0.2.10PBX203.0.113.501SUBSCRIBE02200 OK03NOTIFY (active)04200 OK (NOTIFY)05NOTIFY (active)06200 OK (NOTIFY)07NOTIFY (terminated)⚠08200 OK (NOTIFY)
01/08

Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.

All steps as text
  1. Alice → PBX: SUBSCRIBE. Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.
  2. PBX → Alice: 200 OK. The notifier accepts the subscription. The 200 OK must carry Expires: the duration that counts.
  3. PBX → Alice: NOTIFY (active). The first NOTIFY follows at once, with the full current state.
  4. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms the NOTIFY.
  5. PBX → Alice: NOTIFY (active). Bob answers a call. The PBX reports a confirmed dialog, so Alice's busy lamp for Bob turns red.
  6. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms, and shows the new state.
  7. PBX → Alice: NOTIFY (terminated). Alice's phone never refreshed, and the hour has passed. The notifier ends the subscription. Problem: From now on, Alice sees no changes. Her phone must subscribe again.
  8. Alice → PBX: 200 OK (NOTIFY). Alice's phone confirms. It hears about no further changes.

Remember: refresh every subscription before the Expires in the 200 OK runs out, and earlier if a NOTIFY gives a shorter expires. After terminated;reason=timeout, subscribe again with a new SUBSCRIBE.

Rejecting a NOTIFY that arrives before the 200 OK

A phone creates the subscription dialog only when the 200 OK to its SUBSCRIBE arrives. On a network with a little packet loss, the first NOTIFY sometimes arrives first. The phone finds no dialog, answers 481, and so ends the subscription it has just created. The fault comes and goes, and nobody can reproduce it in the lab.

Broken

Broken: the first NOTIFY gets 481

  • SIP
  • ⚠Problem
Alice192.0.2.10PBX203.0.113.501SUBSCRIBE02NOTIFY (active)03481 Call/Transaction Does Not Exist⚠04200 OK
01/04

Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.

All steps as text
  1. Alice → PBX: SUBSCRIBE. Alice's phone subscribes to Bob's state. Event names the package; Expires asks for an hour.
  2. PBX → Alice: NOTIFY (active). The first NOTIFY overtakes the 200 OK, which a packet loss delays.
  3. Alice → PBX: 481 Call/Transaction Does Not Exist. Alice's phone has no dialog yet, so it rejects the NOTIFY with 481. Problem: A subscriber must accept a NOTIFY that arrives before the 200 OK. The 481 ends the subscription.
  4. PBX → Alice: 200 OK. The notifier accepts the subscription. The 200 OK must carry Expires: the duration that counts.

Remember: a subscriber must accept a NOTIFY that matches a SUBSCRIBE it has sent (same Call-ID, its own tag, same Event), even before the 200 OK. The course’s checker calls this rule notify-early.

Treating a 412 to PUBLISH as a passing error

A softphone refreshes its presence with the stored entity-tag. After a laptop sleeps for longer than the publication lasted, the server has forgotten that state and answers 412 Conditional Request Failed. The softphone keeps refreshing the same entity-tag, gets 412 each time, and the user looks offline all day.

Problem: refreshes the old state

Problem: the refresh fails with 412, and Bob stays offline

  • SIP
  • ⚠Problem
Alice192.0.2.10Presence server203.0.113.15Bob203.0.113.2001PUBLISH (initial)02200 OK03NOTIFY (open)04200 OK (NOTIFY)05NOTIFY (closed)06200 OK (NOTIFY)07PUBLISH (refresh)08412 Conditional Request Failed09PUBLISH (refresh)⚠10412 Conditional Request Failed
01/10

Bob's laptop publishes his presence for an hour.

All steps as text
  1. Bob → Presence server: PUBLISH (initial). Bob's laptop publishes his presence for an hour.
  2. Presence server → Bob: 200 OK. The server stores the state as entity-tag a7f3c1.
  3. Presence server → Alice: NOTIFY (open). Alice watches Bob. Her phone shows him as available.
  4. Alice → Presence server: 200 OK (NOTIFY). Alice's phone updates Bob's icon.
  5. Presence server → Alice: NOTIFY (closed). Bob's laptop sleeps for two hours. His publication expires, so the server reports him as offline.
  6. Alice → Presence server: 200 OK (NOTIFY). Alice's phone updates Bob's icon.
  7. Bob → Presence server: PUBLISH (refresh). The laptop wakes up and refreshes with its stored entity-tag, which no longer exists.
  8. Presence server → Bob: 412 Conditional Request Failed. The server has no state with that entity-tag, so the refresh fails.
  9. Bob → Presence server: PUBLISH (refresh). Later, the laptop tries to refresh again, with the same old entity-tag. Problem: The phone treats the 412 as a passing error. Bob looks offline to everybody, though he is at his desk.
  10. Presence server → Bob: 412 Conditional Request Failed. The same 412, every time. The phone never sends its state again.
RFC 3903 §4.3 · Refreshing Event State
“If there is no matching event state, e.g., the event state to be refreshed has already expired, the EPA receives a 412 (Conditional Request Failed) response to the PUBLISH request.”
Read the section ↗

Remember: after a 412, drop the entity-tag and send a new initial PUBLISH with the full state.

A large MESSAGE over UDP

A chat client sends long messages, such as pasted logs, as MESSAGE over UDP. Above about 1500 bytes the IP layer fragments them. On a network that drops fragments, as many firewalls and NAT routers do, those messages simply never arrive, and the sender gets no error.

Broken

Broken: a 1.5 KB MESSAGE over UDP

  • SIP
  • ⚠Problem
Alice192.0.2.10Proxy B203.0.113.10Bob203.0.113.2001MESSAGE⚠02MESSAGE03200 OK04200 OK
01/04

Alice pastes her meeting notes into a message. Her phone sends all 1.5 KB over UDP.

Above 1300 bytes, UDP splits the packet into IP fragments. If the network drops one fragment, the whole message never arrives.

All steps as text
  1. Alice → Proxy B: MESSAGE. Alice pastes her meeting notes into a message. Her phone sends all 1.5 KB over UDP. Problem: Above 1300 bytes, UDP splits the packet into IP fragments. If the network drops one fragment, the whole message never arrives.
  2. Proxy B → Bob: MESSAGE. Proxy B forwards it over UDP as well, in fragments.
  3. Bob → Proxy B: 200 OK. Bob's phone shows the message.
  4. Proxy B → Alice: 200 OK. This time every fragment arrived. On a busy network, many such messages vanish.

Remember: keep MESSAGE under 1300 bytes, send it over TCP or TLS, or use an MSRP session for long content. The course’s checker calls this rule udp-size (Module 19).

Summary

  • SUBSCRIBE asks for notifications; NOTIFY carries the state. Event names the package, Expires sets the duration, and Subscription-State says active, pending, or terminated, with a reason.
  • The notifier sends a NOTIFY at once after accepting a subscription, and after every change. The first NOTIFY can arrive before the 200 OK.
  • Subscriptions are soft state: refresh before Expires, unsubscribe with Expires: 0.
  • Common packages: presence (PIDF), dialog (busy lamps, pickup), message-summary (voicemail lamp), reg (registration state), and refer (transfer progress).
  • PUBLISH sends state to a presence server; SIP-ETag and SIP-If-Match name the state to refresh, change, or remove. A 412 means: publish the full state again.
  • MESSAGE sends one instant message, with no dialog. 200 means delivered to the UA; 202 means stored for later. Keep it under 1300 bytes, or use MSRP.