| TOC |
|
By submitting this Internet-Draft, each author represents that any applicable patent or other IPR claims of which he or she is aware have been or will be disclosed, and any of which he or she becomes aware will be disclosed, in accordance with Section 6 of BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as “work in progress.”
The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt.
The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html.
This Internet-Draft will expire on January 2, 2009.
Copyright © The IETF Trust (2008).
This document defines the core features of the Extensible Messaging and Presence Protocol (XMPP), a technology for streaming Extensible Markup Language (XML) elements for the purpose of exchanging structured information in close to real time between any two or more network-aware entities. XMPP provides a generalized, extensible framework for incrementally exchanging XML data, upon which a variety of applications can be built. The framework includes methods for stream setup and teardown, channel encryption, authentication of a client to a server and of one server to another server, and primitives for push-style messages, publication of network availability information ("presence"), and request-response interactions. This document also specifies the format for XMPP addresses, which are fully internationalizable.
This document obsoletes RFC 3920.
1.
Introduction
1.1.
Overview
1.2.
Functional Summary
1.3.
Conventions
1.4.
Acknowledgements
1.5.
Discussion Venue
2.
Architecture
2.1.
Overview
2.2.
Server
2.3.
Client
2.4.
Network
3.
Addresses
3.1.
Overview
3.2.
Domain Identifier
3.3.
Node Identifier
3.4.
Resource Identifier
3.5.
Determination of Addresses
4.
TCP Binding
4.1.
Scope
4.2.
Hostname Resolution
4.3.
Client-to-Server Communication
4.4.
Server-to-Server Communication
4.5.
Reconnection
4.6.
Other Bindings
5.
XML Streams
5.1.
Overview
5.2.
Stream Security
5.3.
Stream Attributes
5.3.1.
from
5.3.2.
to
5.3.3.
id
5.3.4.
xml:lang
5.3.5.
version
5.3.6.
Summary of Stream Attributes
5.4.
Namespace Declarations
5.5.
Stream Features
5.6.
Restarts During Stream Negotiation
5.7.
Closing a Stream
5.7.1.
With Stream Error
5.7.2.
Without Stream Error
5.7.3.
Handling of Idle Streams
5.8.
Stream Errors
5.8.1.
Rules
5.8.1.1.
Stream Errors Are Unrecoverable
5.8.1.2.
Stream Errors Can Occur During Setup
5.8.1.3.
Stream Errors When the Host is Unspecified or Unknown
5.8.2.
Syntax
5.8.3.
Defined Stream Error Conditions
5.8.3.1.
bad-format
5.8.3.2.
bad-namespace-prefix
5.8.3.3.
conflict
5.8.3.4.
connection-timeout
5.8.3.5.
host-gone
5.8.3.6.
host-unknown
5.8.3.7.
improper-addressing
5.8.3.8.
internal-server-error
5.8.3.9.
invalid-from
5.8.3.10.
invalid-id
5.8.3.11.
invalid-namespace
5.8.3.12.
invalid-xml
5.8.3.13.
not-authorized
5.8.3.14.
policy-violation
5.8.3.15.
remote-connection-failed
5.8.3.16.
resource-constraint
5.8.3.17.
restricted-xml
5.8.3.18.
see-other-host
5.8.3.19.
system-shutdown
5.8.3.20.
undefined-condition
5.8.3.21.
unsupported-encoding
5.8.3.22.
unsupported-stanza-type
5.8.3.23.
unsupported-version
5.8.3.24.
xml-not-well-formed
5.8.4.
Application-Specific Conditions
5.9.
Simplified Stream Examples
6.
STARTTLS Negotiation
6.1.
Overview
6.2.
Rules
6.2.1.
Data Formatting
6.2.2.
Order of Negotiation
6.3.
Process
6.3.1.
Exchange of Stream Headers and Stream Features
6.3.2.
Initiation of STARTTLS Negotiation
6.3.2.1.
STARTTLS Command
6.3.2.2.
Failure Case
6.3.2.3.
Proceed Case
6.3.3.
TLS Negotiation
6.3.3.1.
Rules
6.3.3.2.
TLS Failure
6.3.3.3.
TLS Success
7.
SASL Negotiation
7.1.
Overview
7.2.
Rules
7.2.1.
Mechanism Preferences
7.2.2.
Mechanism Offers
7.2.3.
Data Formatting
7.2.4.
Security Layers
7.2.5.
Simple Usernames
7.2.6.
Authorization Identities
7.2.7.
Round Trips
7.3.
Process
7.3.1.
Exchange of Stream Headers and Stream Features
7.3.2.
Initiation
7.3.3.
Challenge-Response Sequence
7.3.4.
Abort
7.3.5.
Failure
7.3.6.
Success
7.4.
SASL Errors
7.4.1.
aborted
7.4.2.
account-disabled
7.4.3.
credentials-expired
7.4.4.
encryption-required
7.4.5.
incorrect-encoding
7.4.6.
invalid-authzid
7.4.7.
invalid-mechanism
7.4.8.
malformed-request
7.4.9.
mechanism-too-weak
7.4.10.
not-authorized
7.4.11.
temporary-auth-failure
7.4.12.
transition-needed
7.5.
SASL Definition
8.
Resource Binding
8.1.
Overview
8.2.
Advertising Support
8.3.
Generation of Resource Identifiers
8.4.
Server-Generated Resource Identifier
8.4.1.
Success Case
8.4.2.
Error Cases
8.4.2.1.
Resource Constraint
8.4.2.2.
Not Allowed
8.5.
Client-Submitted Resource Identifier
8.5.1.
Success Case
8.5.2.
Error Cases
8.5.2.1.
Bad Request
8.5.2.2.
Conflict
8.5.3.
Retries
8.6.
Binding Multiple Resources
8.6.1.
Support
8.6.2.
Binding an Additional Resource
8.6.3.
Unbinding a Resource
8.6.3.1.
Success Case
8.6.3.2.
Error Cases
8.6.4.
From Addresses
9.
XML Stanzas
9.1.
Common Attributes
9.1.1.
to
9.1.1.1.
Client-to-Server Streams
9.1.1.2.
Server-to-Server Streams
9.1.2.
from
9.1.2.1.
Client-to-Server Streams
9.1.2.2.
Server-to-Server Streams
9.1.3.
id
9.1.4.
type
9.1.5.
xml:lang
9.2.
Basic Semantics
9.2.1.
Message Semantics
9.2.2.
Presence Semantics
9.2.3.
IQ Semantics
9.3.
Stanza Errors
9.3.1.
Rules
9.3.2.
Syntax
9.3.3.
Defined Conditions
9.3.3.1.
bad-request
9.3.3.2.
conflict
9.3.3.3.
feature-not-implemented
9.3.3.4.
forbidden
9.3.3.5.
gone
9.3.3.6.
internal-server-error
9.3.3.7.
item-not-found
9.3.3.8.
jid-malformed
9.3.3.9.
not-acceptable
9.3.3.10.
not-allowed
9.3.3.11.
not-authorized
9.3.3.12.
not-modified
9.3.3.13.
payment-required
9.3.3.14.
recipient-unavailable
9.3.3.15.
redirect
9.3.3.16.
registration-required
9.3.3.17.
remote-server-not-found
9.3.3.18.
remote-server-timeout
9.3.3.19.
resource-constraint
9.3.3.20.
service-unavailable
9.3.3.21.
subscription-required
9.3.3.22.
undefined-condition
9.3.3.23.
unexpected-request
9.3.3.24.
unknown-sender
9.3.4.
Application-Specific Conditions
9.4.
Extended Content
10.
Examples
10.1.
Client-to-Server
10.1.1.
TLS
10.1.2.
SASL
10.1.3.
Resource Binding
10.1.4.
Stanza Exchange
10.1.5.
Close
10.2.
Server-to-Server Examples
10.2.1.
TLS
10.2.2.
SASL
10.2.3.
Stanza Exchange
10.2.4.
Close
11.
Server Rules for Processing XML Stanzas
11.1.
No 'to' Address
11.1.1.
Overview
11.1.2.
Message
11.1.3.
Presence
11.1.4.
IQ
11.2.
Local Domain
11.2.1.
Mere Domain
11.2.2.
Domain with Resource
11.2.3.
Node at Domain
11.2.3.1.
No Such User
11.2.3.2.
Bare JID
11.2.3.3.
Full JID
11.3.
Foreign Domain
11.3.1.
Existing Stream
11.3.2.
No Existing Stream
11.3.3.
Error Handling
12.
XML Usage
12.1.
Restrictions
12.2.
XML Namespace Names and Prefixes
12.2.1.
Streams Namespace
12.2.2.
Default Namespace
12.2.3.
Extended Namespaces
12.3.
Well-Formedness
12.4.
Validation
12.5.
Inclusion of Text Declaration
12.6.
Character Encoding
12.7.
Whitespace
13.
Compliance Requirements
13.1.
Servers
13.2.
Clients
14.
Internationalization Considerations
15.
Security Considerations
15.1.
High Security
15.2.
Certificates
15.2.1.
Certificate Generation
15.2.1.1.
Server Certificates
15.2.1.2.
Client Certificates
15.2.1.3.
ASN.1 Object Identifier
15.2.2.
Certificate Validation
15.2.2.1.
Server-to-Server Streams
15.2.2.2.
Client-to-Server Streams
15.2.2.3.
Use of Certificates in XMPP Extensions
15.3.
Client-to-Server Communication
15.4.
Server-to-Server Communication
15.5.
Order of Layers
15.6.
Lack of SASL Channel Binding to TLS
15.7.
Mandatory-to-Implement Technologies
15.8.
Firewalls
15.9.
Use of base64 in SASL
15.10.
Stringprep Profiles
15.11.
Address Spoofing
15.11.1.
Address Forging
15.11.2.
Address Mimicking
15.12.
Denial of Service
15.13.
Presence Leaks
15.14.
Directory Harvesting
16.
IANA Considerations
16.1.
XML Namespace Name for TLS Data
16.2.
XML Namespace Name for SASL Data
16.3.
XML Namespace Name for Stream Errors
16.4.
XML Namespace Name for Resource Binding
16.5.
XML Namespace Name for Stanza Errors
16.6.
Nodeprep Profile of Stringprep
16.7.
Resourceprep Profile of Stringprep
16.8.
GSSAPI Service Name
16.9.
Port Numbers
17.
References
17.1.
Normative References
17.2.
Informative References
Appendix A.
Nodeprep
A.1.
Introduction
A.2.
Character Repertoire
A.3.
Mapping
A.4.
Normalization
A.5.
Prohibited Output
A.6.
Bidirectional Characters
A.7.
Notes
Appendix B.
Resourceprep
B.1.
Introduction
B.2.
Character Repertoire
B.3.
Mapping
B.4.
Normalization
B.5.
Prohibited Output
B.6.
Bidirectional Characters
Appendix C.
XML Schemas
C.1.
Streams Namespace
C.2.
Stream Error Namespace
C.3.
STARTTLS Namespace
C.4.
SASL Namespace
C.5.
Resource Binding Namespace
C.6.
Stanza Error Namespace
Appendix D.
Contact Addresses
Appendix E.
Account Provisioning
Appendix F.
Differences From RFC 3920
Appendix G.
Copying Conditions
§
Index
§
Author's Address
§
Intellectual Property and Copyright Statements
| TOC |
| TOC |
The Extensible Messaging and Presence Protocol (XMPP) is an application profile of the Extensible Markup Language [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.) for streaming XML data in close to real time between any two (or more) network-aware entities. XMPP is typically used to exchange messages, share presence information, and engage in structured request-response interactions. The basic syntax and semantics of XMPP were developed originally within the Jabber open-source community, mainly in 1999. In late 2002, the XMPP Working Group was chartered with developing an adaptation of the core Jabber protocol that would be suitable as an IETF instant messaging (IM) and presence technology. As a result of work by the XMPP WG, [RFC3920] (Saint-Andre, P., Ed., “Extensible Messaging and Presence Protocol (XMPP): Core,” October 2004.) and [RFC3921] (Saint-Andre, P., Ed., “Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,” October 2004.) were published in October 2004, representing the most complete definition of XMPP at that time.
As a result of extensive implementation and deployment experience with XMPP since 2004, as well as more formal interoperability testing carried out under the auspices of the XMPP Standards Foundation (XSF), this document reflects consensus from the XMPP developer community regarding XMPP's core XML streaming technology. In particular, this document incorporates the following backward-compatible changes from RFC 3920:
Therefore, this document defines the core features of XMPP 1.0 and obsoletes RFC 3920.
Note: [XMPP‑IM] (Saint-Andre, P., “Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,” June 2008.) defines the XMPP features needed to provide the basic instant messaging and presence functionality that is described in [IMP‑REQS] (Day, M., Aggarwal, S., and J. Vincent, “Instant Messaging / Presence Protocol Requirements,” February 2000.).
| TOC |
This non-normative section provides a developer-friendly, functional summary of XMPP; refer to the sections that follow for a normative definition of XMPP.
The purpose of XMPP is to enable the exchange of relatively small pieces of structured data (called "XML stanzas") over a network between any two (or more) entities. XMPP is implemented using a client-server architecture, wherein a client must connect to a server in order to gain access to the network and thus be allowed to exchange XML stanzas with other entities (which may be associated with other servers). The process whereby a client connects to a server, exchanges XML stanzas, and ends the connection is:
Within XMPP, one server may optionally connect to another server to enable inter-domain or inter-server communication. For this to happen, the two servers must negotiate a connection between themselves and then exchange XML stanzas; the process for doing so is:
* Note: Depending on local service policies, it is possible that a deployed server will use the older server dialback protocol to provide weak identity verification in cases where SASL negotiation would not result in strong authentication (e.g., because TLS negotiation was not mandated by the peer server, or because the certificate presented by the peer server during TLS negotiation is self-signed and thus provides only weak identity); for details, see [XEP‑0220] (Saint-Andre, P. and J. Miller, “Server Dialback,” June 2008.).
In the sections following discussion of XMPP architecture and XMPP addresses, this document specifies how clients connect to servers and specifies the basic semantics of XML stanzas. However, this document does not define the "payloads" of the XML stanzas that might be exchanged once a connection is successfully established; instead, those payloads are defined by various XMPP extensions. For example, [XMPP‑IM] (Saint-Andre, P., “Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,” June 2008.) defines extensions for basic instant messaging and presence functionality. In addition, various specifications produced in the XSF's XEP series [XEP‑0001] (Saint-Andre, P., “XMPP Extension Protocols,” December 2006.) define extensions for a wide range of more advanced functionality.
| TOC |
The following capitalized keywords are to be interpreted as described in [TERMS] (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.): "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
The term "whitespace" is used to refer to any character that matches production [3] content of [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.).
Following the "XML Notation" used in [IRI] (Duerst, M. and M. Suignard, “Internationalized Resource Identifiers (IRIs),” January 2005.) to represent characters that cannot be rendered in ASCII-only documents, some examples in this document use the form "&#x...." as a notational device to represent Unicode characters (e.g., the string "ř" stands for the Unicode character LATIN SMALL LETTER R WITH CARON).
In examples, lines have been wrapped for improved readability, "[...]" means elision, and the following prepended strings are used (these prepended strings are not to be sent over the wire):
| TOC |
The editor of this document finds it impossible to appropriately acknowledge the feedback he has received publicly and privately regarding the core XMPP protocols. However, thanks are due to the many developers who have provided bug reports, requests for clarification, and suggestions for improvement since the publication of RFC 3920. The editor has endeavored to address all such feedback, but is solely responsible for any remaining errors and ambiguities.
| TOC |
The document editor and the broader XMPP developer community welcome discussion and comments related to the topics presented in this document. The preferred forum is the <standards@xmpp.org> mailing list, for which archives and subscription information are available at <http://mail.jabber.org/mailman/listinfo/standards>.
| TOC |
| TOC |
XMPP assumes a client-server architecture, wherein a client utilizing XMPP accesses a server (normally over a [TCP] (Postel, J., “Transmission Control Protocol,” September 1981.) connection) and servers can also communicate with each other over TCP connections.
A simplified architectural diagram for a typical deployment is shown here, where the entities have the following significance:
example.net ---------------- im.example.com
| |
| |
romeo@example.net juliet@im.example.com
Note: Architectures that employ XML streams (XML Streams) and XML stanzas (XML Stanzas) but that establish peer-to-peer connections directly between clients using technologies based on [LINKLOCAL] (Cheshire, S., Aboba, B., and E. Guttman, “Dynamic Configuration of IPv4 Link-Local Addresses,” May 2005.) have been deployed, but such architectures are not XMPP and are best described as "XMPP-like"; for details, see [XEP‑0174] (Saint-Andre, P., “Link-Local Messaging,” June 2007.). In addition, XML streams can be established end-to-end over any reliable transport, including extensions to XMPP itself; for details, see [XEP‑0246] (Saint-Andre, P., “End-to-End XML Streams,” June 2008.).
| TOC |
A SERVER is an entity whose primary responsibilities are to:
Depending on the application, the secondary responsibilities of an XMPP server may include:
| TOC |
A CLIENT is an entity that establishes an XML stream with a server by authenticating using the credentials of a local account and that then completes resource binding (Resource Binding) in order to enable delivery of XML stanzas via the server to the client. A client then uses XMPP to communicate with its server, other clients, and any other accessible entities on a network. Multiple clients may connect simultaneously to a server on behalf of a local account, where each client is differentiated by the resource identifier portion of an XMPP address (e.g., <node@domain/home> vs. <node@domain/work>), as defined under Section 3 (Addresses) and Section 8 (Resource Binding). The RECOMMENDED port for TCP connections between a client and a server is 5222, as registered with the IANA (see Section 16.9 (Port Numbers)).
| TOC |
Because each server is identified by a network address and because server-to-server communication is a straightforward extension of the client-to-server protocol, in practice the system consists of a network of servers that inter-communicate. Thus, for example, <juliet@im.example.com> is able to exchange messages, presence, and other information with <romeo@example.net>. This pattern is familiar from messaging protocols (such as [SMTP] (Klensin, J., “Simple Mail Transfer Protocol,” April 2001.)) that make use of network addressing standards. Communication between any two servers is OPTIONAL. The RECOMMENDED port for TCP connections between servers is 5269, as registered with the IANA (see Section 16.9 (Port Numbers)).
| TOC |
| TOC |
An ENTITY is anything that is network-addressable and that can communicate using XMPP. For historical reasons, the native address of an XMPP entity is called a JABBER IDENTIFIER or JID. A valid JID contains a set of ordered elements formed of an XMPP node identifier, domain identifier, and resource identifier.
The syntax for a JID is defined as follows using the Augmented Backus-Naur Form as specified in [ABNF] (Crocker, D. and P. Overell, “Augmented BNF for Syntax Specifications: ABNF,” October 2005.).
jid = [ node "@" ] domain [ "/" resource ]
node = 1*(nodepoint)
; a "nodepoint" is a UTF-8 encoded Unicode code
; point that satisfies the Nodeprep profile of
; stringprep
domain = fqdn / address-literal / idnlabel
fqdn = (idnlabel 1*("." idnlabel))
; an "idnlabel" is an internationalized label
; as described in RFC 3490
address-literal = IPv4address / IPv6address
; the "IPv4address" and "IPv6address" rules are
; defined in Appendix B of RFC 2373
resource = 1*(resourcepoint)
; a "resourcepoint" is a UTF-8 encoded Unicode
; code point that satisfies the Resourceprep
; profile of stringprep
Note: The "IPv4address" and "IPv6address" rules are indeed provided in [RFC2373] (Hinden, R. and S. Deering, “IP Version 6 Addressing Architecture,” July 1998.) and were removed from [IPv6] (Hinden, R. and S. Deering, “IP Version 6 Addressing Architecture,” February 2006.), which superseded RFC 2373.
All JIDs are based on the foregoing structure. One common use of this structure is to identify a messaging and presence account, the server that hosts the account, and a connected resource (e.g., a specific device) in the form of <node@domain/resource>. However, node types other than clients are possible; for example, a specific chat room offered by a multi-user conference service (see [XEP‑0045] (Saint-Andre, P., “Multi-User Chat,” April 2007.)) could be addressed as <room@service> (where "room" is the name of the chat room and "service" is the hostname of the multi-user conference service) and a specific occupant of such a room could be addressed as <room@service/nick> (where "nick" is the occupant's room nickname). Many other JID types are possible (e.g., <domain/resource> could be a server-side script or service).
Each allowable portion of a JID (node identifier, domain identifier, and resource identifier) MUST NOT be more than 1023 bytes in length, resulting in a maximum total size (including the '@' and '/' separators) of 3071 bytes.
Note: While the format of a JID is consistent with [URI] (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.), an entity's address on an XMPP network MUST be represented as a JID (without a URI scheme) and not a [URI] (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.) or [IRI] (Duerst, M. and M. Suignard, “Internationalized Resource Identifiers (IRIs),” January 2005.) as specified in [XMPP‑URI] (Saint-Andre, P., “Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP),” February 2008.); the latter specification is provided only for identification and interaction outside the context of the XMPP wire protocol itself.
| TOC |
The DOMAIN IDENTIFIER portion of a JID is that portion after the '@' character (if any) and before the '/' character (if any); it is the primary identifier and is the only REQUIRED element of a JID (a mere domain identifier is a valid JID). Typically a domain identifier identifies the "home" server to which clients connect for XML routing and data management functionality. However, it is not necessary for an XMPP domain identifier to identify an entity that provides core XMPP server functionality (e.g., a domain identifier can identity an entity such as a multi-user conference service, a publish-subscribe service, or a user directory).
Note: A single server can service multiple domain identifiers, i.e., multiple local domains; this is typically referred to as virtual hosting.
The domain identifier for every server or service that will communicate over a network SHOULD be a fully qualified domain name (see [DNS] (Mockapetris, P., “Domain names - implementation and specification,” November 1987.)); while the domain identifier MAY be either an Internet Protocol (IPv4 or IPv6) address or a text label that is resolvable on a local network (commonly called an "unqualified hostname"), it is possible that domain identifiers that are IP addresses will not be acceptable to other services for the sake of interdomain communication. Furthermore, domain identifiers that are unqualified hostnames MUST NOT be used on public networks but MAY be used on private networks.
Note: If the domain identifier includes a final character considered to be a label separator (dot) by [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.) or [STD13] (Mockapetris, P., “Domain names - implementation and specification,” November 1987.), this character MUST be stripped from the domain identifier before the JID of which it is a part is used for the purpose of routing an XML stanza, comparing against another JID, or constructing an [XMPP‑URI] (Saint-Andre, P., “Internationalized Resource Identifiers (IRIs) and Uniform Resource Identifiers (URIs) for the Extensible Messaging and Presence Protocol (XMPP),” February 2008.); in particular, the character MUST be stripped before any other canonicalization steps are taken, such as application of the [NAMEPREP] (Hoffman, P. and M. Blanchet, “Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN),” March 2003.) profile of [STRINGPREP] (Hoffman, P. and M. Blanchet, “Preparation of Internationalized Strings ("stringprep"),” December 2002.) or completion of the ToASCII operation as described in [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.).
A domain identifier MUST be an "internationalized domain name" as defined in [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.), that is, "a domain name in which every label is an internationalized label". When preparing a text label (consisting of a sequence of Unicode code points) for representation as an internationalized label in the process of constructing an XMPP domain identifier or comparing two XMPP domain identifiers, an application MUST ensure that for each text label it is possible to apply without failing the ToASCII operation specified in [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.) with the UseSTD3ASCIIRules flag set (thus forbidding ASCII code points other than letters, digits, and hyphens). If the ToASCII operation can be applied without failing, then the label is an internationalized label. An internationalized domain name (and therefore an XMPP domain identifier) is constructed from its constituent internationalized labels by following the rules specified in [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.).
Note: The ToASCII operation includes application of the [NAMEPREP] (Hoffman, P. and M. Blanchet, “Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN),” March 2003.) profile of [STRINGPREP] (Hoffman, P. and M. Blanchet, “Preparation of Internationalized Strings ("stringprep"),” December 2002.) and encoding using the algorithm specified in [PUNYCODE] (Costello, A., “Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA),” March 2003.); for details, see [IDNA] (Faltstrom, P., Hoffman, P., and A. Costello, “Internationalizing Domain Names in Applications (IDNA),” March 2003.). Although the output of the ToASCII operation is not used in XMPP, it MUST be possible to apply that operation without failing.
| TOC |
The NODE IDENTIFIER portion of a JID is an optional secondary identifier placed before the domain identifier and separated from the latter by the '@' character. Typically a node identifier uniquely identifies the entity requesting and using network access provided by a server (i.e., a local account), although it can also represent other kinds of entities (e.g., a chat room associated with a multi-user conference service). The entity represented by an XMPP node identifier is addressed within the context of a specific domain.
A node identifier MUST be formatted such that the Nodeprep profile of [STRINGPREP] (Hoffman, P. and M. Blanchet, “Preparation of Internationalized Strings ("stringprep"),” December 2002.) can be applied without failing (see Appendix A (Nodeprep)). Before comparing two node identifiers, an application MUST first ensure that the Nodeprep profile has been applied to each identifier (the profile need not be applied each time a comparison is made, as long as it has been applied before comparison).
| TOC |
The RESOURCE IDENTIFIER portion of a JID is an optional tertiary identifier placed after the domain identifier and separated from the latter by the '/' character. A resource identifier can modify either a <node@domain> address or a mere <domain> address. Typically a resource identifier uniquely identifies a specific connection (e.g., a device or location) or object (e.g., a participant in a multi-user conference room) belonging to the entity associated with an XMPP node identifier at a local domain.
When an XMPP address does not include a resource identifier (i.e., when it is of the form <domain> or <node@domain>), it is referred to as a BARE JID. When an XMPP address includes a resource identifier (i.e., when it is of the form <domain/resource> or <node@domain/resource>), is referred to as a FULL JID.
A resource identifier MUST be formatted such that the Resourceprep profile of [STRINGPREP] (Hoffman, P. and M. Blanchet, “Preparation of Internationalized Strings ("stringprep"),” December 2002.) can be applied without failing (see Appendix B (Resourceprep)). Before comparing two resource identifiers, an application MUST first ensure that the Resourceprep profile has been applied to each identifier (the profile need not be applied each time a comparison is made, as long as it has been applied before comparison).
Note: For historical reasons, the term "resource identifier" is used in XMPP to refer to the optional portion of an XMPP address that follows the domain identifier and the "/" separator character; this use of the term "resource identifier" is not to be confused with the meanings of "resource" and "identifier" provided in Section 1.1 of [URI] (Berners-Lee, T., Fielding, R., and L. Masinter, “Uniform Resource Identifier (URI): Generic Syntax,” January 2005.).
XMPP entities SHOULD consider resource identifiers to be opaque strings and SHOULD NOT impute meaning to any given resource identifier. In paticular, the use of the '/' character as a separator between the domain identifier and the resource identifier does not imply that resource identifiers are hierarchical in the say that, say, HTTP addresses are hierarchical; thus for example an XMPP address of the form <node@domain/foo/bar> does not identify a resource "bar" that exists below a resource "foo" in a hierarchy of resources associated with the entity "node@domain".
| TOC |
After the parties to an XML stream have completed the appropriate aspects of stream negotiation (typically SASL negotiation (SASL Negotiation) and, if appropriate, resource binding (Resource Binding)) the receiving entity for a stream MUST determine the initiating entity's JID.
For server-to-server communication, the initiating server's JID MUST be the authorization identity (as defined by [SASL] (Melnikov, A. and K. Zeilenga, “Simple Authentication and Security Layer (SASL),” June 2006.)), either (1) as directly communicated by the initiating server during SASL negotiation (SASL Negotiation) or (2) as derived by the receiving server from the authentication identity if no authorization identity was specified during SASL negotiation (SASL Negotiation). (For information about the determination of addresses in the absence of SASL negotiation when the older server dialback protocol is used, see [XEP‑0220] (Saint-Andre, P. and J. Miller, “Server Dialback,” June 2008.).)
For client-to-server communication, the client's bare JID (<node@domain>) MUST be the authorization identity (as defined by [SASL] (Melnikov, A. and K. Zeilenga, “Simple Authentication and Security Layer (SASL),” June 2006.)), either (1) as directly communicated by the client during SASL negotiation (SASL Negotiation) or (2) as derived by the server from the authentication identity if no authorization identity was specified during SASL negotiation (SASL Negotiation). The resource identifier portion of the full JID (<node@domain/resource>) MUST be the resource identifier negotiated by the client and server during resource binding (Resource Binding).
The receiving entity MUST ensure that the resulting JID (including node identifier, domain identifier, resource identifier, and separator characters) conforms to the rules and formats defined earlier in this section; to meet this restriction, the receiving entity MAY replace the JID sent by the initiating entity with the canonicalized JID as determined by the receiving entity.
| TOC |
| TOC |
As XMPP is defined in this specification, an initiating entity (client or server) MUST open a Transmission Control Protocol [TCP] (Postel, J., “Transmission Control Protocol,” September 1981.) connection at the receiving entity (server) before it negotiates XML streams with the receiving entity. The rules specified in the following sections apply to the TCP binding.
| TOC |
Before opening the TCP connection, the initiating entity first MUST resolve the Domain Name System (DNS) hostname associated with the receiving entity and determine the appropriate TCP port for communication with the receiving entity. The process is:
Note: Many XMPP servers are implemented in such a way that they can host additional services (beyond those defined in this specification and [XMPP‑IM] (Saint-Andre, P., “Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence,” June 2008.)) at hostnames that are subdomains of the hostname of the main XMPP service (e.g., conference.example.net for a [XEP‑0045] (Saint-Andre, P., “Multi-User Chat,” April 2007.) service associated with the example.net XMPP service) or subdomains of the first-level domain of the underlying host (e.g., muc.example.com for a [XEP‑0045] (Saint-Andre, P., “Multi-User Chat,” April 2007.) service associated with the im.example.com XMPP service). If an entity from a remote domain wishes to use such additional services, it would generate an appropriate XML stanza and the remote domain itself would attempt to resolve the service's hostname via an SRV lookup on resource records such as "_xmpp-server._tcp.conference.example.net." or "_xmpp-server._tcp.muc.example.com.". Therefore if a service wishes to enable entities from remote domains to access these additional services, it needs to advertise the appropriate "_xmpp-server" SRV records in addition to the "_xmpp-server" record for its main XMPP service.
| TOC |
Because a client is subordinate to a server and therefore a client authenticates to the server but the server does not necessarily authenticate to the client, it is necessary to have only one TCP connection between client and server. Thus the server MUST allow the client to share a single TCP connection for XML stanzas sent from client to server and from server to client (i.e., the inital stream and response stream as specified under Section 5 (XML Streams)).
| TOC |
Because two servers are peers and therefore each peer must authenticate with the other, the servers MUST use two TCP connections: one for XML stanzas sent from the first server to the second server and another (initiated by the second server) for XML stanzas from the second server to the first server.
This rule applies only to XML stanzas (XML Stanzas). Therefore during STARTTLS negotiation (STARTTLS Negotiation) and SASL negotiation (SASL Negotiation) the servers would use one TCP connection, but after stream setup that TCP connection would be used only for the initiating server to send XML stanzas to the receiving server. In order for the receiving server to send XML stanzas to the initiating server, the receiving server would need to reverse the roles and negotiate an XML stream from the receiving server to the initiating server.
| TOC |
It can happen that an XMPP server goes offline while servicing TCP connections from local clients and from other servers. Because the number of such connections can be quite large, the reconnection algorithm employed by entities that seek to reconnect can have a significant impact on software and network performance. The following guidelines are RECOMMENDED:
Note: Because it is possible that a disconnected entity cannot determine the cause of disconnection (e.g., because there was no explicit stream error) or does not require a new stream for immediate communication (e.g., because the stream was idle and therefore timed out), it SHOULD NOT assume that is needs to reconnect immediately.
| TOC |
There is no necessary coupling of an XML stream to a TCP connection. For example, two entities could connect to each other via another transport, such as [HTTP] (Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., and T. Berners-Lee, “Hypertext Transfer Protocol -- HTTP/1.1,” June 1999.) as specified in [XEP‑0124] (Paterson, I., Smith, D., and P. Saint-Andre, “Bidirectional-streams Over Synchronous HTTP (BOSH),” February 2007.) and [XEP‑0206] (Paterson, I., “XMPP Over BOSH,” June 2007.). Although this specification neither encourages nor discourages other bindings, it defines only a binding of XMPP to TCP.
| TOC |
| TOC |
Two fundamental concepts make possible the rapid, asynchronous exchange of relatively small payloads of structured information between presence-aware entities: XML streams and XML stanzas. These terms are defined as follows.
- Definition of XML Stream:
- An XML STREAM is a container for the exchange of XML elements between any two entities over a network. The start of an XML stream is denoted unambiguously by an opening STREAM HEADER (i.e., an XML <stream> tag with appropriate attributes and namespace declarations), while the end of the XML stream is denoted unambiguously by a closing XML </stream> tag. During the life of the stream, the entity that initiated it can send an unbounded number of XML elements over the stream, either elements used to negotiate the stream (e.g., to complete TLS negotiation (STARTTLS Negotiation) or SASL negotiation (SASL Negotiation)) or XML stanzas. The INITIAL STREAM is negotiated from the initiating entity (typically a client or server) to the receiving entity (typically a server), and can be seen as corresponding to the initiating entity's "connection" or "session" with the receiving entity. The initial stream enables unidirectional communication from the initiating entity to the receiving entity; in order to enable information exchange from the receiving entity to the initiating entity, the receiving entity MUST negotiate a stream in the opposite direction (the RESPONSE STREAM).
- Definition of XML Stanza:
- An XML STANZA is a discrete semantic unit of structured information that is sent from one entity to another over an XML stream, and is the basic unit of meaning in XMPP. An XML stanza exists at the direct child level of the root <stream/> element; the start of any XML stanza is denoted unambiguously by the element start tag at depth=1 of the XML stream (e.g., <presence>), and the end of any XML stanza is denoted unambiguously by the corresponding close tag at depth=1 (e.g., </presence>). The only XML stanzas defined herein are the <message/>, <presence/>, and <iq/> elements qualified by the default namespace for the stream, as described under Section 9 (XML Stanzas); for example, an XML element sent for the purpose of TLS negotiation (STARTTLS Negotiation) or SASL negotiation (SASL Negotiation) is not considered to be an XML stanza, nor is a stream error or a stream feature. An XML stanza MAY contain child elements (with accompanying attributes, elements, and XML character data) as necessary in order to convey the desired information, which MAY be qualified by any XML namespace (see [XML‑NAMES] (Bray, T., Hollander, D., and A. Layman, “Namespaces in XML,” January 1999.) as well as Section 9.4 (Extended Content) herein).
Consider the example of a client's connection to a server. In order to connect to a server, a client initiates an XML stream by sending a stream header to the server, optionally preceded by a text declaration specifying the XML version and the character encoding supported (see Section 12.5 (Inclusion of Text Declaration) and Section 12.6 (Character Encoding)). Subject to local policies and service provisioning, the server then replies with a second XML stream back to the client, again optionally preceded by a text declaration. Once the client has completed SASL negotiation (SASL Negotiation) and resource binding (Resource Binding), the client can send an unbounded number of XML stanzas over the stream. When the client desires to close the stream, it simply sends a closing </stream> tag to the server as further described under Section 5.7 (Closing a Stream).
In essence, then, an XML stream acts as an envelope for all the XML stanzas sent during a connection. We can represent this in a simplistic fashion as follows.
+--------------------+ | <stream> | |--------------------| | <presence> | | <show/> | | </presence> | |--------------------| | <message to='foo'> | | <body/> | | </message> | |--------------------| | <iq to='bar'> | | <query/> | | </iq> | |--------------------| | <iq from='bar'> | | <query/> | | </iq> | |--------------------| | [ ... ] | |--------------------| | </stream> | +--------------------+
Note: Those who are accustomed to thinking of XML in a document-centric manner may wish to view a client's connection to a server as consisting of two open-ended XML documents: one from the client to the server and one from the server to the client. On this analogy, the two XML streams can be considered equivalent to two "documents" (matching production [1] content of [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.)) that are built up through the accumulation of XML stanzas, the root <stream/> element can be considered equivalent to the "document entity" for each "document" (as described in Section 4.8 of [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.)), and the XML stanzas sent over the streams can be considered equivalent to "fragments" of the "documents" as described in [XML‑FRAG] (Grosso, P. and D. Veillard, “XML Fragment Interchange,” February 2001.). However, this perspective is merely an analogy; XMPP does not deal in documents and fragments but in streams and stanzas.
| TOC |
For the purpose of stream security, both Transport Layer Security (see Section 6 (STARTTLS Negotiation)) and the Simple Authentication and Security Layer (see Section 7 (SASL Negotiation)) are mandatory to implement. Use of these technologies results in high security as described under Section 15.1 (High Security).
The initial stream and the response stream MUST be secured separately, although security in both directions MAY be established via mechanisms that provide mutual authentication.
The initiating entity MUST NOT attempt to send XML stanzas (XML Stanzas) over the stream before the stream has been authenticated. However, if it does attempt to do so, the receiving entity MUST NOT accept such stanzas and MUST return a <not-authorized/> stream error. This rule applies to XML stanzas only (i.e., <message/>, <presence/>, and <iq/> elements qualified by the default namespace) and not to XML elements used for stream negotiation (e.g., elements used to complete TLS negotiation (STARTTLS Negotiation) or SASL negotiation (SASL Negotiation)).
| TOC |
The attributes of the root <stream/> element are defined in the following sections.
Note: The attributes of the root <stream/> element are not prepended by a 'stream:' prefix because, in accordance with Section 5.3 of [XML‑NAMES] (Bray, T., Hollander, D., and A. Layman, “Namespaces in XML,” January 1999.), the default namespace does not apply to attribute names.
| TOC |
The 'from' attribute communicates an XMPP identity of the entity sending the stream element.
Note: It is possible for an entity to have more than one XMPP identity (e.g., in the case of a server that provides virtual hosting). It is also possible that an entity does not know the XMPP identity of the principal controlling the entity (e.g., because the XMPP identity is assigned at a level other than the XMPP application layer, as in the General Security Service Application Program Interface [GSS‑API] (Linn, J., “Generic Security Service Application Program Interface Version 2, Update 1,” January 2000.)).
For initial stream headers in client-to-server communication, if the client knows the XMPP identity of the principal controlling the client (typically an account name of the form <node@domain>), then it MUST include the 'from' attribute and MUST set its value to that identity. If the client does not know the XMPP identity of the principal controlling the client, then it MUST NOT include the 'from' attribute.
I: <?xml version='1.0'?>
<stream:stream
from='juliet@im.example.com'
to='im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
For initial stream headers in server-to-server communication, a server MUST include the 'from' attribute and MUST set its value to a hostname serviced by the initiating entity.
I: <?xml version='1.0'?>
<stream:stream
from='example.net'
to='im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:server'
xmlns:stream='http://etherx.jabber.org/streams'>
For response stream headers in both client-to-server and server-to-server communication, the receiving entity MUST include the 'from' attribute and MUST set its value to a hostname serviced by the receiving entity (which MAY be a hostname other than that specified in the 'to' attribute of the initial stream header).
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
Whether or not the 'from' attribute is included, each entity MUST verify the identity of the other entity before exchanging XML stanzas with it (see Section 15.3 (Client-to-Server Communication) and Section 15.4 (Server-to-Server Communication)).
Note: It is possible that implementations based on an earlier revision of this specification will not include the 'from' address on stream headers; an entity SHOULD be liberal in accepting such stream headers.
| TOC |
For initial stream headers in both client-to-server and server-to-server communication, the initiating entity MUST include the 'to' attribute and MUST set its value to a hostname that the initiating entity knows or expects the receiving entity to service.
I: <?xml version='1.0'?>
<stream:stream
from='juliet@im.example.com'
to='im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
For response stream headers in client-to-server communication, if the client included a 'from' attribute in the initial stream header then the server MUST include a 'to' attribute in the response stream header and MUST set its value to the bare JID specified in the 'from' attribute of the initial stream header. If the client did not include a 'from' attribute in the initial stream header then the server MUST NOT include a 'to' attribute in the response stream header.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
For response stream headers in server-to-server communication, the receiving entity MUST include a 'to' attribute in the response stream header and MUST set its value to the hostname specified in the 'from' attribute of the initial stream header.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='g4qSvGvBxJ+xeAd7QKezOQJFFlw='
to='example.net'
version='1.0'
xml:lang='en'
xmlns='jabber:server'
xmlns:stream='http://etherx.jabber.org/streams'>
Whether or not the 'to' attribute is included, each entity MUST verify the identity of the other entity before exchanging XML stanzas with it (see Section 15.3 (Client-to-Server Communication) and Section 15.4 (Server-to-Server Communication)).
Note: It is possible that implementations based on an earlier revision of this specification will not include the 'from' address on stream headers; an entity SHOULD be liberal in accepting such stream headers.
| TOC |
The 'id' attribute communicates a unique identifier for the stream. This identifier is called a STREAM ID. The stream ID MUST be generated by the receiving entity when it sends a response stream header, MUST BE unique within the receiving application (normally a server), and MUST be both unpredictable and nonrepeating because it can be security-critical (see [RANDOM] (Eastlake, D., Schiller, J., and S. Crocker, “Randomness Requirements for Security,” June 2005.) for recommendations regarding randomness for security purposes).
For initial stream headers, the initiating entity MUST NOT include the 'id' attribute; however, if the 'id' attribute is included, the receiving entity MUST silently ignore it.
For response stream headers, the receiving entity MUST include the 'id' attribute.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
| TOC |
The 'xml:lang' attribute communicates an entity's preferred or default language for any human-readable XML character data to be sent over the stream. The syntax of this attribute is defined in Section 2.12 of [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.); in particular, the value of the 'xml:lang' attribute MUST conform to the NMTOKEN datatype (as defined in Section 2.3 of [XML] (Paoli, J., Maler, E., Sperberg-McQueen, C., Yergeau, F., and T. Bray, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.)) and MUST conform to the language identifier format defined in [LANGTAGS] (Phillips, A. and M. Davis, “Tags for Identifying Languages,” September 2006.).
For initial stream headers, the initiating entity SHOULD include the 'xml:lang' attribute.
I: <?xml version='1.0'?>
<stream:stream
from='juliet@im.example.com'
to='im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
For response stream headers, the receiving entity MUST include the 'xml:lang' attribute. If the initiating entity included an 'xml:lang' attribute in its initial stream header and the receiving entity supports that language in the human-readable XML character data that it generates and sends to the initiating entity (e.g., in the <text/> element for stream and stanza errors), the value of the 'xml:lang' attribute MUST be identifier for the initiating entity's preferred language; if the receiving entity supports a language that closely matches the initiating entity's preferred language (e.g., "de" instead of "de-CH"), then the value of the 'xml:lang' attribute SHOULD be the identifier for the matching language but MAY be the identifier for the default language of the receiving entity; if the receiving entity does not support the initiating entity's preferred language or a closely matching language (or the initiating entity did not include the 'xml:lang' attribute in its initial stream header), then the value of the 'xml:lang' attribute MUST be the identifier for the default language of the receiving entity.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
If the initiating entity included the 'xml:lang' attribute in its initial stream header, the receiving entity SHOULD remember that value as the default xml:lang for all stanzas sent by the initiating entity. As described under Section 9.1.5 (xml:lang), the initiating entity MAY include the 'xml:lang' attribute in any XML stanzas it sends over the stream. If the initiating entity does not include the 'xml:lang' attribute in any such stanza, the receiving entity SHOULD add the 'xml:lang' attribute to the stanza, whose value MUST be the identifier for the language preferred by the initiating entity (even if the receiving entity does not support that language for human-readable XML character data it generates and sends to the initiating entity, such as in stream or stanza errors). If the initiating entity includes the 'xml:lang' attribute in any such stanza, the receiving entity MUST NOT modify or delete it.
| TOC |
The inclusion of the version attribute set to a value of at least "1.0" signals support for the stream-related protocols defined in this specification, including (TLS negotiation (STARTTLS Negotiation), SASL negotiation (SASL Negotiation), Section 5.5 (Stream Features), and stream errors (Stream Errors).
The version of XMPP specified herein is "1.0"; in particular, XMPP 1.0 encapsulates the stream-related protocols as well as the basic semantics of the three defined XML stanza types (<message/>, <presence/>, and <iq/>).
The numbering scheme for XMPP versions is "<major>.<minor>". The major and minor numbers MUST be treated as separate integers and each number MAY be incremented higher than a single digit. Thus, "XMPP 2.4" would be a lower version than "XMPP 2.13", which in turn would be lower than "XMPP 12.3". Leading zeros (e.g., "XMPP 6.01") MUST be ignored by recipients and MUST NOT be sent.
The major version number will be incremented only if the stream and stanza formats or required actions have changed so dramatically that an older version entity would not be able to interoperate with a newer version entity if it simply ignored the elements and attributes it did not understand and took the actions specified in the older specification.
The minor version number will be incremented only if significant new capabilities have been added to the core protocol (e.g., a newly defined value of the 'type' attribute for message, presence, or IQ stanzas). The minor version number MUST be ignored by an entity with a smaller minor version number, but MAY be used for informational purposes by the entity with the larger minor version number (e.g., the entity with the larger minor version number would simply note that its correspondent would not be able to understand that value of the 'type' attribute and therefore would not send it).
The following rules apply to the generation and handling of the 'version' attribute within stream headers:
| TOC |
The following table summarizes the attributes of the root <stream/> element.
+----------+--------------------------+-------------------------+ | | initiating to receiving | receiving to initiating | +----------+--------------------------+-------------------------+ | to | JID of receiver | JID of initiator | | from | JID of initiator | JID of receiver | | id | silently ignored | stream identifier | | xml:lang | default language | default language | | version | XMPP 1.0+ supported | XMPP 1.0+ supported | +----------+--------------------------+-------------------------+
| TOC |
The stream element MUST possess both a streams namespace declaration and a default namespace declaration (as "namespace declaration" is defined in [XML‑NAMES] (Bray, T., Hollander, D., and A. Layman, “Namespaces in XML,” January 1999.)). For detailed information regarding the streams namespace and default namespace, see Section 12.2 (XML Namespace Names and Prefixes).
| TOC |
If the initiating entity includes the 'version' attribute set to a value of at least "1.0" in the initial stream header, after sending the response stream header the receiving entity MUST send a <features/> child element (prefixed by the streams namespace prefix) to the initiating entity in order to announce any stream-level features that can be negotiated or capabilities that otherwise need to be advertised.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
R: <stream:features>
<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
<required/>
</starttls>
</stream:features>
Stream features are used mainly to advertise TLS negotiation (STARTTLS Negotiation), SASL negotiation (SASL Negotiation), and resource binding (Resource Binding); however, stream features also can be used to advertise features associated with various XMPP extensions. If an entity does not understand or support a feature that has been advertised, it MUST silently ignore the associated feature advertisement.
If it is necessary for a feature to be successfully negotiated before the initiating entity is allowed to proceed with the sending of XML stanzas or with further steps of the stream negotiation, the advertisement of that feature MUST include an empty <required/> child element.
R: <stream:features>
<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
<required/>
</bind>
</stream:features>
If successful negotiation of a feature is discretionary, the advertisement of that feature MUST include an empty <optional/> child element.
R: <stream:features>
<session xmlns='urn:ietf:params:xml:ns:xmpp-session'>
<optional/>
</session>
</stream:features>
Note: Implementations based on an earlier revision of this specification do not include the <optional/> child element and they include the <required/> child element only in the case of the STARTTLS feature. Entities MUST accept stream feature advertisements without the child elements, and SHOULD consider consider negotiation of such features to be discretionary.
If it is necessary for a feature to be successfully negotiated before the initiating entity is allowed to proceed with the sending a non-security-related feature or with further steps of the stream negotiation, the receiving entity SHOULD NOT advertise any other stream features until the mandatory feature has been successfully negotiated; however, if the mandatory feature is security-critical (e.g., STARTTLS or SASL) then the receiving entity MUST NOT advertise any other stream features until the security-critical feature has been successfully negotiated.
The order of child elements contained in any given <features/> element is not significant.
After completing negotiation of any stream feature (even stream features that do not require a stream restart), the receiving entity MUST send an updated list of stream features to the initiating entity. However, if there are no features to be advertised then the receiving entity MUST send an empty <features/> element.
R: <?xml version='1.0'?>
<stream:stream
from='im.example.com'
id='++TR84Sm6A3hnt3Q065SnAbbk3Y='
to='juliet@im.example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>
R: <stream:features/>
At any time after stream establishment, the receiving entity MAY send additional or modified stream feature advertisements (e.g., because a new feature has been enabled).
| TOC |
Certain stream features require the initiating entity to send a new initial stream header on successful negotiation of the feature (e.g., after successful negotiation of TLS or SASL). Both parties MUST consider the previous stream to be replaced on successful feature negotiation but MUST NOT terminate the underlying TCP connection; instead, the parties MUST reuse the existing connection, which might be in a new state (e.g., encrypted as a result of TLS negotiation). When the receiving entity receives the new initial stream header, it MUST generate a new stream ID (instead of re-using the old stream ID) before sending a new response stream header.
| TOC |
An XML stream between two entities can be closed because a stream error has occurred or in some cases in the absence of an error. Where feasible, it is preferable to close a stream only if a stream error has occurred.
A stream is closed by sending a closing </stream> tag over the TCP connection.
S: </stream:stream>
After an entity sends a closing stream tag, it MUST NOT send further data over that stream.
| TOC |
If a stream error has occurred, the entity that detects the error MUST close the stream as described under Section 5.8.1 (Rules).