Request for Comments: 3921 Jabber Software Foundation
Category: Standards Track October 2004
Extensible Messaging and Presence Protocol (XMPP):
Instant Messaging and Presence
Status of this Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2004).
Abstract
This memo describes extensions to and applications of the core
features of the Extensible Messaging and Presence Protocol (XMPP)
that provide the basic instant messaging (IM) and presence
functionality defined in RFC 2779.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Syntax of XML Stanzas . . . . . . . . . . . . . . . . . . . 4
3. Session Establishment . . . . . . . . . . . . . . . . . . . 10
4. Exchanging Messages . . . . . . . . . . . . . . . . . . . . 13
5. Exchanging Presence Information . . . . . . . . . . . . . . 16
6. Managing Subscriptions . . . . . . . . . . . . . . . . . . . 26
7. Roster Management . . . . . . . . . . . . . . . . . . . . . 27
8. Integration of Roster Items and Presence Subscriptions . . . 32
9. Subscription States . . . . . . . . . . . . . . . . . . . . 56
10. Blocking Communication . . . . . . . . . . . . . . . . . . . 62
11. Server Rules for Handling XML Stanzas . . . . . . . . . . . 85
12. IM and Presence Compliance Requirements . . . . . . . . . . 88
13. Internationalization Considerations . . . . . . . . . . . . 89
14. Security Considerations . . . . . . . . . . . . . . . . . . 89
15. IANA Considerations . . . . . . . . . . . . . . . . . . . . 90
16. References . . . . . . . . . . . . . . . . . . . . . . . . . 91
A. vCards . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
B. XML Schemas. . . . . . . . . . . . . . . . . . . . . . . . . 93
C. Differences Between Jabber IM/Presence Protocols and XMPP. . 105
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 106
Author’s Address. . . . . . . . . . . . . . . . . . . . . . . . . 106
Full Copyright Statement. . . . . . . . . . . . . . . . . . . . . 107
1. Introduction
1.1. Overview
The Extensible Messaging and Presence Protocol (XMPP) is a protocol
for streaming XML [XML] elements in order to exchange messages and
presence information in close to real time. The core features of
XMPP are defined in Extensible Messaging and Presence Protocol
(XMPP): Core [XMPP-CORE]. These features -- mainly XML streams, use
of TLS and SASL, and the <message/>, <presence/>, and <iq/> children
of the stream root -- provide the building blocks for many types of
near-real-time applications, which may be layered on top of the core
by sending application-specific data qualified by particular XML
namespaces [XML-NAMES]. This memo describes extensions to and
applications of the core features of XMPP that provide the basic
functionality expected of an instant messaging (IM) and presence
application as defined in RFC 2779 [IMP-REQS].
1.2. Requirements
For the purposes of this memo, the requirements of a basic instant
messaging and presence application are defined by [IMP-REQS], which
at a high level stipulates that a user must be able to complete the
following use cases:
o Exchange messages with other users
o Exchange presence information with other users
o Manage subscriptions to and from other users
o Manage items in a contact list (in XMPP this is called a "roster")
o Block communications to or from specific other users
Detailed definitions of these functionality areas are contained in
[IMP-REQS], and the interested reader is directed to that document
regarding the requirements addressed herein.
[IMP-REQS] also stipulates that presence services must be separable
from instant messaging services; i.e., it must be possible to use the
protocol to provide a presence service, an instant messaging service,
or both. Although the text of this memo assumes that implementations
and deployments will want to offer a unified instant messaging and
presence service, there is no requirement that a service must offer
both a presence service and an instant messaging service, and the
protocol makes it possible to offer separate and distinct services
for presence and for instant messaging.
Note: While XMPP-based instant messaging and presence meets the
requirements of [IMP-REQS], it was not designed explicitly with that
specification in mind, since the base protocol evolved through an
open development process within the Jabber open-source community
before RFC 2779 was written. Note also that although protocols
addressing many other functionality areas have been defined in the
Jabber community, such protocols are not included in this memo
because they are not required by [IMP-REQS].
1.3. Terminology
This memo inherits the terminology defined in [XMPP-CORE].
The capitalized key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP
14, RFC 2119 [TERMS].
2. Syntax of XML Stanzas
The basic semantics and common attributes of XML stanzas qualified by
the ’jabber:client’ and ’jabber:server’ namespaces are defined in
[XMPP-CORE]. However, these namespaces also define various child
elements, as well as values for the common ’type’ attribute, that are
specific to instant messaging and presence applications. Thus,
before addressing particular "use cases" for such applications, we
here further describe the syntax of XML stanzas, thereby
supplementing the discussion in [XMPP-CORE].
2.1. Message Syntax
Message stanzas qualified by the ’jabber:client’ or ’jabber:server’
namespace are used to "push" information to another entity. Common
uses in instant messaging applications include single messages,
messages sent in the context of a chat conversation, messages sent in
the context of a multi-user chat room, headlines and other alerts,
and errors.
2.1.1. Types of Message
The ’type’ attribute of a message stanza is RECOMMENDED; if included,
it specifies the conversational context of the message, thus
providing a hint regarding presentation (e.g., in a GUI). If
included, the ’type’ attribute MUST have one of the following values:
o chat -- The message is sent in the context of a one-to-one chat
conversation. A compliant client SHOULD present the message in an
interface enabling one-to-one chat between the two parties,
including an appropriate conversation history.
o error -- An error has occurred related to a previous message sent
by the sender (for details regarding stanza error syntax, refer to
[XMPP-CORE]). A compliant client SHOULD present an appropriate
interface informing the sender of the nature of the error.
o groupchat -- The message is sent in the context of a multi-user
chat environment (similar to that of [IRC]). A compliant client
SHOULD present the message in an interface enabling many-to-many
chat between the parties, including a roster of parties in the
chatroom and an appropriate conversation history. Full definition
of XMPP-based groupchat protocols is out of scope for this memo.
o headline -- The message is probably generated by an automated
service that delivers or broadcasts content (news, sports, market
information, RSS feeds, etc.). No reply to the message is
expected, and a compliant client SHOULD present the message in an
interface that appropriately differentiates the message from
standalone messages, chat sessions, or groupchat sessions (e.g.,
by not providing the recipient with the ability to reply).
o normal -- The message is a single message that is sent outside the
context of a one-to-one conversation or groupchat, and to which it
is expected that the recipient will reply. A compliant client
SHOULD present the message in an interface enabling the recipient
to reply, but without a conversation history.
An IM application SHOULD support all of the foregoing message types;
if an application receives a message with no ’type’ attribute or the
application does not understand the value of the ’type’ attribute
provided, it MUST consider the message to be of type "normal" (i.e.,
"normal" is the default). The "error" type MUST be generated only in
response to an error related to a message received from another
entity.
Although the ’type’ attribute is OPTIONAL, it is considered polite to
mirror the type in any replies to a message; furthermore, some
specialized applications (e.g., a multi-user chat service) MAY at
their discretion enforce the use of a particular message type (e.g.,
type=’groupchat’).
2.1.2. Child Elements
As described under extended namespaces (Section 2.4), a message
stanza MAY contain any properly-namespaced child element.
In accordance with the default namespace declaration, by default a
message stanza is qualified by the ’jabber:client’ or ’jabber:server’
namespace, which defines certain allowable children of message
stanzas. If the message stanza is of type "error", it MUST include
an <error/> child; for details, see [XMPP-CORE]. Otherwise, the
message stanza MAY contain any of the following child elements
without an explicit namespace declaration:
1. <subject/>
2. <body/>
3. <thread/>
2.1.2.1. Subject
The <subject/> element contains human-readable XML character data
that specifies the topic of the message. The <subject/> element MUST
NOT possess any attributes, with the exception of the ’xml:lang’
attribute. Multiple instances of the <subject/> element MAY be
included for the purpose of providing alternate versions of the same
subject, but only if each instance possesses an ’xml:lang’ attribute
with a distinct language value. The <subject/> element MUST NOT
contain mixed content (as defined in Section 3.2.2 of [XML]).
2.1.2.2. Body
The <body/> element contains human-readable XML character data that
specifies the textual contents of the message; this child element is
normally included but is OPTIONAL. The <body/> element MUST NOT
possess any attributes, with the exception of the ’xml:lang’
attribute. Multiple instances of the <body/> element MAY be included
but only if each instance possesses an ’xml:lang’ attribute with a
distinct language value. The <body/> element MUST NOT contain mixed
content (as defined in Section 3.2.2 of [XML]).
2.1.2.3. Thread
The <thread/> element contains non-human-readable XML character data
specifying an identifier that is used for tracking a conversation
thread (sometimes referred to as an "instant messaging session")
between two entities. The value of the <thread/> element is
generated by the sender and SHOULD be copied back in any replies. If
used, it MUST be unique to that conversation thread within the stream
and MUST be consistent throughout that conversation (a client that
receives a message from the same full JID but with a different thread
ID MUST assume that the message in question exists outside the
context of the existing conversation thread). The use of the
<thread/> element is OPTIONAL and is not used to identify individual
messages, only conversations. A message stanza MUST NOT contain more
than one <thread/> element. The <thread/> element MUST NOT possess
any attributes. The value of the <thread/> element MUST be treated
as opaque by entities; no semantic meaning may be derived from it,
and only exact comparisons may be made against it. The <thread/>
element MUST NOT contain mixed content (as defined in Section 3.2.2
of [XML]).
2.2. Presence Syntax
Presence stanzas are used qualified by the ’jabber:client’ or
’jabber:server’ namespace to express an entity’s current network
availability (offline or online, along with various sub-states of the
latter and optional user-defined descriptive text), and to notify
other entities of that availability. Presence stanzas are also used
to negotiate and manage subscriptions to the presence of other
entities.
2.2.1. Types of Presence
The ’type’ attribute of a presence stanza is OPTIONAL. A presence
stanza that does not possess a ’type’ attribute is used to signal to
the server that the sender is online and available for communication.
If included, the ’type’ attribute specifies a lack of availability, a
request to manage a subscription to another entity’s presence, a
request for another entity’s current presence, or an error related to
a previously-sent presence stanza. If included, the ’type’ attribute
MUST have one of the following values:
o unavailable -- Signals that the entity is no longer available for
communication.
o subscribe -- The sender wishes to subscribe to the recipient’s
presence.
o subscribed -- The sender has allowed the recipient to receive
their presence.
o unsubscribe -- The sender is unsubscribing from another entity’s
presence.
o unsubscribed -- The subscription request has been denied or a
previously-granted subscription has been cancelled.
o probe -- A request for an entity’s current presence; SHOULD be
generated only by a server on behalf of a user.
o error -- An error has occurred regarding processing or delivery of
a previously-sent presence stanza.
For detailed information regarding presence semantics and the
subscription model used in the context of XMPP-based instant
messaging and presence applications, refer to Exchanging Presence
Information (Section 5) and Managing Subscriptions (Section 6).
2.2.2. Child Elements
As described under extended namespaces (Section 2.4), a presence
stanza MAY contain any properly-namespaced child element.
In accordance with the default namespace declaration, by default a
presence stanza is qualified by the ’jabber:client’ or
’jabber:server’ namespace, which defines certain allowable children
of presence stanzas. If the presence stanza is of type "error", it
MUST include an <error/> child; for details, see [XMPP-CORE]. If the
presence stanza possesses no ’type’ attribute, it MAY contain any of
the following child elements (note that the <status/> child MAY be
sent in a presence stanza of type "unavailable" or, for historical
reasons, "subscribe"):
1. <show/>
2. <status/>
3. <priority/>
2.2.2.1. Show
The OPTIONAL <show/> element contains non-human-readable XML
character data that specifies the particular availability status of
an entity or specific resource. A presence stanza MUST NOT contain
more than one <show/> element. The <show/> element MUST NOT possess
any attributes. If provided, the XML character data value MUST be
one of the following (additional availability types could be defined
through a properly-namespaced child element of the presence stanza):
o away -- The entity or resource is temporarily away.
o chat -- The entity or resource is actively interested in chatting.
o dnd -- The entity or resource is busy (dnd = "Do Not Disturb").
o xa -- The entity or resource is away for an extended period (xa =
"eXtended Away").
If no <show/> element is provided, the entity is assumed to be online
and available.
2.2.2.2. Status
The OPTIONAL <status/> element contains XML character data specifying
a natural-language description of availability status. It is
normally used in conjunction with the show element to provide a
detailed description of an availability state (e.g., "In a meeting").
The <status/> element MUST NOT possess any attributes, with the
exception of the ’xml:lang’ attribute. Multiple instances of the
<status/> element MAY be included but only if each instance possesses
an ’xml:lang’ attribute with a distinct language value.
2.2.2.3. Priority
The OPTIONAL <priority/> element contains non-human-readable XML
character data that specifies the priority level of the resource. The
value MUST be an integer between -128 and +127. A presence stanza
MUST NOT contain more than one <priority/> element. The <priority/>
element MUST NOT possess any attributes. If no priority is provided,
a server SHOULD consider the priority to be zero. For information
regarding the semantics of priority values in stanza routing within
instant messaging and presence applications, refer to Server Rules
for Handling XML Stanzas (Section 11).
2.3. IQ Syntax
IQ stanzas provide a structured request-response mechanism. The
basic semantics of that mechanism (e.g., that the ’id’ attribute is
REQUIRED) are defined in [XMPP-CORE], whereas the specific semantics
required to complete particular use cases are defined in all cases by
an extended namespace (Section 2.4) (note that the ’jabber:client’
and ’jabber:server’ namespaces do not define any children of IQ
stanzas other than the common <error/>). This memo defines two such
extended namespaces, one for Roster Management (Section 7) and the
other for Blocking Communication (Section 10); however, an IQ stanza
MAY contain structured information qualified by any extended
namespace.
2.4. Extended Namespaces
While the three XML stanza kinds defined in the "jabber:client" or
"jabber:server" namespace (along with their attributes and child
elements) provide a basic level of functionality for messaging and
presence, XMPP uses XML namespaces to extend the stanzas for the
purpose of providing additional functionality. Thus a message or
presence stanza MAY contain one or more optional child elements
specifying content that extends the meaning of the message (e.g., an
XHTML-formatted version of the message body), and an IQ stanza MAY
contain one such child element. This child element MAY have any name
and MUST possess an ’xmlns’ namespace declaration (other than
"jabber:client", "jabber:server", or
"http://etherx.jabber.org/streams") that defines all data contained
within the child element.
Support for any given extended namespace is OPTIONAL on the part of
any implementation (aside from the extended namespaces defined
herein). If an entity does not understand such a namespace, the
entity’s expected behavior depends on whether the entity is (1) the
recipient or (2) an entity that is routing the stanza to the
recipient:
Recipient: If a recipient receives a stanza that contains a child
element it does not understand, it SHOULD ignore that specific XML
data, i.e., it SHOULD not process it or present it to a user or
associated application (if any). In particular:
* If an entity receives a message or presence stanza that
contains XML data qualified by a namespace it does not
understand, the portion of the stanza that is in the unknown
namespace SHOULD be ignored.
* If an entity receives a message stanza whose only child element
is qualified by a namespace it does not understand, it MUST
ignore the entire stanza.
* If an entity receives an IQ stanza of type "get" or "set"
containing a child element qualified by a namespace it does not
understand, the entity SHOULD return an IQ stanza of type
"error" with an error condition of <service-unavailable/>.
Router: If a routing entity (usually a server) handles a stanza that
contains a child element it does not understand, it SHOULD ignore
the associated XML data by passing it on untouched to the
recipient.
3. Session Establishment
Most instant messaging and presence applications based on XMPP are
implemented via a client-server architecture that requires a client
to establish a session on a server in order to engage in the expected
instant messaging and presence activities. However, there are
several pre-conditions that MUST be met before a client can establish
an instant messaging and presence session. These are:
1. Stream Authentication -- a client MUST complete stream
authentication as documented in [XMPP-CORE] before attempting to
establish a session or send any XML stanzas.
2. Resource Binding -- after completing stream authentication, a
client MUST bind a resource to the stream so that the client’s
address is of the form <user@domain/resource>, after which the
entity is now said to be a "connected resource" in the
terminology of [XMPP-CORE].
If a server supports sessions, it MUST include a <session/> element
qualified by the ’urn:ietf:params:xml:ns:xmpp-session’ namespace in
the stream features it advertises to a client after the completion of
stream authentication as defined in [XMPP-CORE]:
Server advertises session establishment feature to client:
<stream:stream
xmlns=’jabber:client’
xmlns:stream=’http://etherx.jabber.org/streams’
id=’c2s_345’
from=’example.com’
version=’1.0’>
<stream:features>
<bind xmlns=’urn:ietf:params:xml:ns:xmpp-bind’/>
<session xmlns=’urn:ietf:params:xml:ns:xmpp-session’/>
</stream:features>
Upon being so informed that session establishment is required (and
after completing resource binding), the client MUST establish a
session if it desires to engage in instant messaging and presence
functionality; it completes this step by sending to the server an IQ
stanza of type "set" containing an empty <session/> child element
qualified by the ’urn:ietf:params:xml:ns:xmpp-session’ namespace:
Step 1: Client requests session with server:
<iq to=’example.com’
type=’set’
id=’sess_1’>
<session xmlns=’urn:ietf:params:xml:ns:xmpp-session’/>
</iq>
Step 2: Server informs client that session has been created:
<iq from=’example.com’
type=’result’
id=’sess_1’/>
Upon establishing a session, a connected resource (in the terminology
of [XMPP-CORE]) is said to be an "active resource".
Several error conditions are possible. For example, the server may
encounter an internal condition that prevents it from creating the
session, the username or authorization identity may lack permissions
to create a session, or there may already be an active resource
associated with a resource identifier of the same name.
If the server encounters an internal condition that prevents it from
creating the session, it MUST return an error.
Step 2 (alt): Server responds with error (internal server error):
<iq from=’example.com’ type=’error’ id=’sess_1’>
<session xmlns=’urn:ietf:params:xml:ns:xmpp-session’/>
<error type=’wait’>
<internal-server-error
xmlns=’urn:ietf:params:xml:ns:xmpp-stanzas’/>
</error>
</iq>
If the username or resource is not allowed to create a session, the
server MUST return an error (e.g., forbidden).
Step 2 (alt): Server responds with error (username or resource not
allowed to create session):
<iq from=’example.com’ type=’error’ id=’sess_1’>
<session xmlns=’urn:ietf:params:xml:ns:xmpp-session’/>
<error type=’auth’>