SUBSCRIBE and NOTIFY (rfc 3265)
- ability to receive asynchronous notification of events, on subscription
- general concept is that the entities in the network can SUBSCRIBE (which needs to be refreshed periodically) to resource or call state, and be notified when the state changes
- SUBSCRIBE requests create a dialog
- terms and definitions
- Event Package, set of state info to be reported by a notifier to a SUBSCRIBEr
- Event Template Package, special kind of event package which defines a set of event packages with a set od states which may be applied to all possible event packages
- Notification, act of sending a NOTIFY message to the SUBSCRIBER, informaing the state of resource
- Notifier, UA which generates the NOTIFY request, and typically accepts SUBSCRIBE request to create subscriptions
- State Agent, notifier which publishes the state on behalf of a resource, they may need to gather such info from multiple sources
- SUBSCRIBER, UA which receives a NOTIFY request, typically generate SUBSCRIBE request
- subscription is a set of application state associated with a dialog, containing a pointer to the associate dialog, the even package name, and an identifiction token
- Subscription Migration, act of moving a subscription from one notifier to another
- "Expires" Header
- SUBSCRIBE requests should contain an "Expires" header, indicating the duration of subscription
- if no "Expires" header is present then the implied default defined in the even package is used
- 200 class response to a SUBSCRIBE request must contain an "Expires" header, the period can be shorter(but not longer) than specified in the request
- SUBSCRIBE with an "Expires" of 0 means
- Identification of Events and Event Classes
- Request URI, Event Type and Optionally Message Body
- SUBSCRIBErs must include exactly one "Event" header in SUBSCRIBE requests, indication which event or class of events they are subscribing
- the "Event" header may contain an "id" param which identifies a specific subscription with in a dialog, "id" is only valid within the scope of a single dialog
- Additional SUBSCRIBE Header values
- as the SUBSCRIBE request create a dialog, they may contain a "Accept" header, if present it indicates the body formats allowed in subsequent NOTIFY requests.
- Subscription behavior
- intial SUSCRIBE request is generally a request outside of a dialog
- the SUBSCRIBE request will be confirmed with a final response (200 class), and a NOTIFY will be send immediately
- the "Expires" header in a 200 class response indicates the actual duration for which the subscription will remain active
- a SUBSCRIBE request may contiain an "id" param in its "Event" header to differentiate between multiple subscriptions in the same dialog
- the "489 bad event" is used to indicate that the server did not understand the even package specefied in the "Event" header field
- refershing of subscriptions
- by sending another SUBSCRIBE ewquest on the same dialog as the existing subscription and with the same "Event" header and "id" parameter if present
- if the "id" param is not present in the initial SUBSCRIBE and refresh SUBSCRIBE will contain an "id" param, it will be considered as a anew subscription in the existing dialog
- a "481 call/transaction does not exist" response to refresh SUBSCRIBE means that the subscription has been terminated
- unsubscribing
- done by setting the "Expires" header to "0"
- a successfull unsubscription will also trigger a NOTIFY message
- proxy SUBSCRIBE behavior
- if a proxy wishes to see all of the SUBSCRIBE and NOTIFY requests for a given dialog it must record-route the initial SUBSCRIBE and any dialog establishing NOTIFY requests
- notifier SUBSCRIBE behavior
- notifiers must not wait for a user response before returning a final response to a SUBSCRIBE request
- if the "Event" header is not understood then the notifier should return a "489 bad event" response
- notifier should perform any necessary authentication and authorization
- notifier may also check that the duration in the "Expires" header is too small, if the expiration is greater than zero AND smaller than one hour AND less than a notifier configured minimum, the notifier may return a "423 Interval too small" error which containes a "Min-Expires" header field
- if the notifier cannot immediately create the subscription, it will return a "202 Accepted" response
- when a sunscription is created in the notifier, it stores the event package name and the "Event" header "id" param as part of the subscription information
- the server must not lenghten (can shorten it) the "Expires" header value in the SUBSCRIBE 200 class responses (same as in REGSTER response),
- state information will be communicated via a subsequent NOTIFY request from the notifer
- authentication for a SUBSCRIBE request will always be performed via a "401 unauthorized" response, not a "407 proxy authentication required", notifiers always act as a user agents when accepting subscriptions and sending notifications
- if the authorization fails the notifer should reply to the request with a "403 forbidden" or a "603 decline" response
- notifier may convey authorization declined, by sending a NOTIFY message containing a "Subscription-State" header with a value of "terminated" and a reason param of "rejected"
- on receiving a subscription refresh, the notifer (server) may shorten the amount of time until expiration, but must not increase it
- if the duration specified in the SUBSCRIBE is unacceptably short the notifier should respond with a "423 subscription too brief"
- on removing a subscription the notifier should send a NOTIFY message with a "Subscription-State" value of "terminated" and "reason=timeout" param, this NOTIFY also allows the corresponding dialog to be terminated
- knowledge of a subscription must exist between both the SUBSCRIBEr and the notifier
- sending a NOTIFY to a endpoint which is unaware of the subscription, results in a response "481 Subscription does not exist"
- a single SUBSCRIBE may trigger several NOTIFY
- as in SUBSCRIBE request, NOTIFY "Event" headers will contain a single event package name in the for which a notification is being send, and the event name must match the name in the "Event" header of the corresponding SUBSCRIBE, the "id" (same as SUBSCRIBE) must also be present
- a NOTIFY request is considered failed if the response times out, or a non-200 class response code is received which has no "Retry-After" header
- if a NOTIFY fails due to timeout condition, and the subscription was installed using soft-state mechanism (such as SUBSCRIBE), the NOTIFIER should remove the subscription (this behavior prevents unnecessary transmission of state information for the SUBSCRIBErs who have crashed or disappeared from the network)
- if a NOTIFY request receives a "481 call leg/transaction does not exist" response the notifier must remove the corresponding subscription, even if the subscription was installed by non-SUBSCRIBE means (eg administrative interface)
- NOTIFY requests must contain a "Subscription-State" header with a value of "active", "pending", or "terminated".
- "active" means that the subscription has been accepted
- "pending" means subscription has been received
- "terminated" means that the subscription is not active
- for "active" or "pending" value an "Expires" param should be included
- for "terminated" state notifier should also include any of the following "reason" param
- deactivated, subscription terminated, SUBSCRIBEr should retry immediately with a new subscription
- probation, subscription terminated, SUBSCRIBEr should retry after some time (use "retry-after" if present)
- rejected, subscription rejected due to change in the authorization policy, SUBSCRIBEr should not attempt to re-SUBSCRIBE
- timeout, subscription terminated as it was not refershed before it expired, SUBSCRIBEr may reSUBSCRIBE immediately
- giveup, subscription terminated because the notifier could not obtain authorization in a timely fashion
- noresource, subscription terminated, as the resource state which was being monitored no longer exists
- detecting support for SUBSCRIBE and NOTIFY
- clients may probe for the support of SUBSCRIBE and NOTIFY using the OPTIONS request
- the presence of "Allow-Events" header in a message is sufficient to indicate support for SUBSCRIBE and NOTIFY
- the "methods" parameter for Contact may also be used to specifically announce support for SUBSCRIBE and NOTIFY messages while registering.
- forking scenarios
- successfull SUBSCRIBE requests wil receive only one 200-class response
- due to forking, the subscription may be accepted by multiple nodes, thus there may me more than one NOTIFY requests with "From:" tags which differ from the "To:" tag received in the SUBSCRIBE 200-class response.
- if multiple NOTIFY message received in different dialog in response to a single SUBSCRIBE, each dilaog represent a different destination to which the SUBSCRIBE request is forked
- dialog creation and termination
- the initial SUBSCRIBE request is not sent on a pre-existing dialog, a response to the SUBSCRIBE or a matching NOTIFY will make the complete dialog
- matching is done on basis of "Call-ID", "From" header "tag" and the same "Cseq".
- if a 200-class response matches the SUBSCRIBE, it creates a new subscription and a new dialog (if its not already there)
- NOTIFY request are matched to such SUBSCRIBE, by matching "Call-ID", "To" tag parameter of NOTIFY and "From" "tag" of SUBSCRIBE, and the same "Event" header field
- multiple subscriptions can be associated with a single dialog
- for the purpose of subscription and dialog lifetime, a subscription is destroyed when a notifier sends a NOTIFY request with a "Subscription-State" of "terminated"
- in the case of several subscription are associated with a single dialog, the dialog does not terminate until all the subscriptions in it are destroyed
- polling resource state
- an immediate fetch of the state without a persistent subscription ("Expires" greater than 0) may be effected by sending a SUBSCRIBE with "Expires" of 0
- NOTIFY messages triggered by SUBSCRIBE with "Expires" as 0 will contain a "Subscription-State" of "terminated" and a "reason" param of "timeout"
- Allow-Events header
- a node sending an "Allow-Events" header is advertising that it can process SUBSCRIBE and generate NOTIFY for all the event pacakges listed in the header
- the "Allow-Event" headers must not be inserted by proxies
Reference :http://www.ietf.org/rfc/rfc3265.txt
No comments:
Post a Comment