The BOSH (XEP-0124) [1] protocol defines how arbitrary XML elements can be transported efficiently and reliably over HTTP in both directions between a client and server. This document defines some minor extensions to BOSH that enable XMPP streams (as specified in XMPP Core [2]) to be bound to HTTP.
If the BOSH <body/> wrapper is not empty, then it SHOULD contain one of the following:
Note: Many existing XMPP-specific implementations of BOSH clients and connection managers do not specify the namespace of <message/>, <presence/>, or <iq/> elements, since that allows them to forward stanzas without modification (the XMPP <stream:stream/> wrapper element used with TCP typically sets the default namespace to 'jabber:client'). They instead simply assume that the full content of the 'jabber:client' namespace is a subset of the 'http://jabber.org/protocol/httpbind' namespace.
Note: Inclusion of TLS negotiation elements is allowed but is NOT RECOMMENDED. The definition of how TLS might be implemented over BOSH is currently beyond the scope of this document. Instead, channel encryption SHOULD be completed at the HTTP (transport) layer, not the XMPP (application) layer.
The client SHOULD include a 'version' attribute qualified by the 'urn:xmpp:xbosh' namespace in its session creation request. This attribute corresponds to the 'version' attribute of the XMPP <stream:stream/> element as defined in RFC 6120 [2]. The connection manager SHOULD forward the value to the XMPP server accordingly.
The connection manager can use the 'from' and 'to' attributes to populate the same attributes on the stream header sent from the connection manager to the XMPP server, or can use them for session management purposes specific to the connection manager implementation.
Note: Unlike the protocol defined in Jabber HTTP Polling (XEP-0025) [3], an opening <stream:stream> tag is not sent to the connection manager (since BOSH <body/> elements MUST not contain partial XML elements). Any XML streams between the connection manager and an XMPP server are the responsibility of the connection manager (and beyond the scope of this document).
The connection manager SHOULD include a 'version' attribute (qualified by the 'urn:xmpp:xbosh' namespace) and a <stream:features/> element (qualified by the 'http://etherx.jabber.org/streams' namespace) in a response as soon as they are available, either in its session creation response, or (if it has not yet received them from the XMPP server) in any subsequent response.
If the connection manager supports stream restarts, it MUST advertise that fact by including a 'restartlogic' attribute (qualified by the 'urn:xmpp:xbosh' namespace) whose value is set to "true" [4]. It is STRONGLY RECOMMENDED for all XMPP connection managers to support stream restarts, since they are an integral aspect of stream negotiation in XMPP. However, note that some older BOSH implementations do not explicitly advertise support for stream restarts.
Note: The same procedure applies to the obsolete XMPP-specific 'authid' attribute of the BOSH <body/> element, which contains the value of the XMPP stream ID generated by the XMPP server. This value is needed only by legacy XMPP clients in order to complete digest authentication using the obsolete Non-SASL Authentication (XEP-0078) [5] protocol. [6]
If no <stream:features/> element is included in the connection manager's session creation response, then the client SHOULD send empty request elements until it receives a response containing a <stream:features/> element.
Note: The client SHOULD ignore any Transport Layer Security (TLS) feature since BOSH channel encryption SHOULD be negotiated at the HTTP layer.
TLS compression (as defined in RFC 6120 [2]) and Stream Compression (as defined in Stream Compression (XEP-0138) [7]) are NOT RECOMMENDED since compression SHOULD be negotiated at the HTTP layer using the 'accept' attribute of the BOSH session creation response. TLS compression and Stream Compression SHOULD NOT be used at the same time as HTTP content encoding.
Note: The 'version' attribute qualified by the 'urn:xmpp:xbosh' namespace SHOULD also be included on the request and response when adding new streams to a session.
A success case for authentication and resource binding using the XMPP protocols is shown below. For detailed specification of these protocols (including error cases), refer to RFC 6120 [2]. The server MAY offer the SASL-EXTERNAL method, for example when BOSH is used in conjunction with HTTP authentication or TLS authentication on the HTTP level.
Upon receiving the <success/> element, the client MUST then ask the connection manager to restart the stream by sending a "restart request" that is structured as follows:
When SASL-EXTERNAL is used in combination with BOSH the BOSH <body/> element SHOULD include the 'from' attribute upon stream restart. This because constrained clients can not always know what credentials were used to authenticate on the HTTP level. The server MUST try to associate the provided 'from' with the credentials that were provided on the other level.
The following example illustrates the format for a restart request.
Upon receiving a restart request, the connection manager MUST consider the previous stream with the XMPP server to be closed. It MUST then initiate a new stream by sending an opening <stream:stream> tag over the same TCP connection to the XMPP server. If the connection manager receives a <stream:features/> element from the XMPP server, it MUST forward that element to the client:
The client can then complete any mandatory or discretionary stream feature negotiations.
The content of the <body/> element is zero or more stanzas followed by a copy of the <stream:error/> element [9] (qualified by the 'http://etherx.jabber.org/streams' namespace) received from the XMPP server:
It is possible that a connection manager will receive a stanza for delivery to a client even though the client connection is no longer active (e.g., before the connection manager is able to inform the XMPP server that the connection has died). In this case, the connection manager would return an error to the XMPP server; it is RECOMMENDED that the connection manager proceed as follows, since the situation is similar to that addressed by point #2 of Section 11.1 of RFC 6121 [10]
When an XMPP server receives a <message/> stanza of type "error" containing a <recipient-unavailable/> condition from a connection manager, it SHOULD store the message for later delivery if offline storage is enabled (see Best Practices for Handling Offline Messages (XEP-0160) [11]), otherwise route the error stanza to the sender.
This protocol does not introduce any new security considerations beyond those specified in BOSH and XMPP Core.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [12].
The XMPP Registrar [13] includes 'urn:xmpp:xbosh' in its registry of protocol namespaces.
Thanks to Dave Cridland, Steffen Larsen, Matt Miller, Jack Moffitt, Stefan Strigler, Mike Taylor, Winfried Tilanus, Ashley Ward, and Matthew Wild for their feedback.
Thanks to Kevin Winters for his assistance with the schema.
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).
Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.
## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.
This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).
The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.
Errata can be sent to <editor@xmpp.org>.
The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
1. XEP-0124: Bidirectional-streams Over Synchronous HTTP <https://xmpp.org/extensions/xep-0124.html>.
2. RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc6120>.
3. XEP-0025: Jabber HTTP Polling <https://xmpp.org/extensions/xep-0025.html>.
4. In accordance with Section 3.2.2.1 of XML Schema Part 2: Datatypes, the allowable lexical representations for the xs:boolean datatype are the strings "0" and "false" for the concept 'false' and the strings "1" and "true" for the concept 'true'; implementations MUST support both styles of lexical representation.
5. XEP-0078: Non-SASL Authentication <https://xmpp.org/extensions/xep-0078.html>.
6. Separate 'sid' and 'authid' attributes are required because the connection manager is not necessarily part of a single XMPP server (e.g., it may handle HTTP connections on behalf of multiple XMPP servers).
7. XEP-0138: Stream Compression <https://xmpp.org/extensions/xep-0138.html>.
8. It is known that some connection manager implementations accept an XML stanza in the body of the restart request and send that stanza to the server when the stream is restarted; however there is no guarantee that a connection manager will send the stanza so a client cannot rely on this behavior.
9. Earlier obsolete versions of this protocol specified that the <body/> element should contain only the content of the <stream:error/> element.
10. RFC 6121: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc6121>.
11. XEP-0160: Best Practices for Handling Offline Messages <https://xmpp.org/extensions/xep-0160.html>.
12. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
13. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>.
Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/
Incorporated patches from community review.
Added 'restartlogic' attribute per XSF ticket SPEC-8; added note about use of the 'from' and 'to' attributes from XEP-0124 in relation to XML stream headers as specified in RFC 6120.
Clarified handling of xbosh restart -- client MUST send the restart and the body MUST be empty; removed IM session establishment examples because that protocol is deprecated in RFC 6121; corrected XML schema.
remote-stream-error includes full <stream:error/> element (not just its content) and optional stanzas
Initial version (extracted from XEP-0124 version 1.5); deprecated non-SASL authentication and authid attribute; multiple clarifications and restructuring without changes to protocol itself; added optional version and restart attributes.
@report{paterson2007xbosh, title = {XMPP Over BOSH}, author = {Paterson, Ian and Saint-Andre, Peter and Stout, Lance and Tilanus, Winfried}, type = {XEP}, number = {0206}, version = {1.4}, institution = {XMPP Standards Foundation}, url = {https://xmpp.org/extensions/xep-0206.html}, date = {2007-02-28/2014-04-09}, }
END