The standard client-server architecture for XMPP communication provides a stable infrastructure for real-time communication. However, there are certain situations in which it is desirable to bypass the standard client-server architecture, including:
The first situation is addressed by Link-Local Messaging (XEP-0174) . However, if the endpoints already have client-to-server connections but wish to bypass those connections or leverage those streams for a higher-level application such as end-to-end encryption, it is desirable for the two endpoints to negotiate an end-to-end XML stream. This specification defines methods for doing so, where the application format is an XML stream and the transport method is any direct or mediated streaming transport, such as Jingle In-Band Bytestreams Transport Method (XEP-0261)  (mediated), Jingle SOCKS5 Bytestreams Transport Method (XEP-0260)  (direct or mediated), or a future ice-tcp Jingle transport (direct or mediated) based on RFC 6544 .
This section provides a friendly introduction to Jingle XML streams.
First, the party that wishes to initiate the stream determines the responder's capabilities (via Service Discovery (XEP-0030)  or Entity Capabilities (XEP-0115) ). Here we assume that the responder supports a service discovery feature of 'urn:xmpp:jingle:apps:xmlstream:0' (see Namespace Versioning regarding the possibility of incrementing the version number) corresponding to the Jingle XML stream functionality defined herein, as well as the 'urn:xmpp:jingle:transports:ibb:0' feature.
The initiator then sends a Jingle session-initiation request to the responder. The content-type of the request specifies three things:
An application type of "urn:xmpp:jingle:apps:xmlstream:0".
Options for the streaming transport method, such as In-Band Bytestreams ("IBB") as defined in XEP-0261 or SOCKS5 Bytestreams ("S5B") as defined in XEP-0260.
Note: It is STRONGLY RECOMMENDED to encrypt all end-to-end XML streams as described in Jingle-XTLS (currently located at <http://xmpp.org/extensions/inbox/jingle-xtls.html>). Those security flows are NOT described here.
In this example, the initiator is <email@example.com>, the responder is <firstname.lastname@example.org>, and the initiation request specifies a transport method of "jingle-ibb" (i.e., XEP-0261).
The flow is as follows.
First the initiator sends a Jingle session-initiate.
The responder immediately acknowledges receipt of the Jingle session-initiate.
If the responding user accepts the session then her client sends a session-accept.
The initiator acknowledges receipt.
The clients can then begin to exchange XMPP data over the in-band bytestream. Because the transport is an in-band bytestream, the XMPP data is prepared as described in In-Band Bytestreams (XEP-0047)  (i.e., Base64-encoded).
First the initiator sends an initial stream header to the responder.
Note: In accordance with XMPP IM , the initial stream header SHOULD include the 'to' and 'from' attributes, which SHOULD specify the full JIDs of the clients. If the initiator supports stream features and the other stream-related aspects of XMPP 1.0 as specified in RFC 3920, then it SHOULD include the version='1.0' flag as shown in the previous example.
The responder then sends a response stream header back to the initiator (because this stream header is sent in the other direction, the IBB 'seq' attribute has a value of zero, not 1).
Once the streams are established, either entity then can send XMPP message, presence, and IQ stanzas, with or without 'to' and 'from' addresses.
The responder could then send a reply.
To end the XML stream, either party sends a closing </stream:stream> element.
However, even after the application-level XML stream is terminated, the negotiated Jingle transport (here in-band bytestream) continues and could be re-used. To completely terminate the Jingle session, the terminating party would then also send a Jingle session-terminate message.
The other party then acknowledges the Jingle session-terminate.
An implementations MUST support the Jingle IBB Transport Method (XEP-0261) as a dependable method of last resort. An implementation SHOULD support other streaming transport methods as well, such as the Jingle S5B Transport Method (XEP-0260).
An application MAY present transport methods in any order, except that the Jingle IBB Transport Method MUST be the lowest preference.
No interaction with the Internet Assigned Numbers Authority (IANA)  is required as a result of this document.
This specification defines the following XML namespace:
Upon advancement of this specification from a status of Experimental to a status of Draft, the XMPP Registrar  shall add the foregoing namespaces to the registry located at <https://xmpp.org/registrar/namespaces.html>, as described in Section 4 of XMPP Registrar Function (XEP-0053) .
If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.
The XMPP Registrar shall include "xmlstream" in its registry of Jingle application formats. The registry submission is as follows:
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2020 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 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 <email@example.com> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.
Errata can be sent to <firstname.lastname@example.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".
9. 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/>.
10. 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 http://xmpp.org/extensions/attic/
Adjusted text and examples to reflect Jingle-XTLS, Jingle-IBB, and Jingle-S5B; moved stream security to Jingle-XTLS; moved basic stream setup from XEP-0246 to this document; changed examples to use Jingle-IBB as the transport; clarified stream opening and closing as well as session termination.
Initial published version.