draft-ietf-xmpp-websocket-02.txt   draft-ietf-xmpp-websocket-03.txt 
XMPP Working Group L. Stout, Ed. XMPP Working Group L. Stout, Ed.
Internet-Draft &yet Internet-Draft &yet
Intended status: Standards Track J. Moffitt Intended status: Standards Track J. Moffitt
Expires: September 15, 2014 Mozilla Expires: October 21, 2014 Mozilla
E. Cestari E. Cestari
cstar industries cstar industries
March 14, 2014 April 19, 2014
An XMPP Sub-protocol for WebSocket An XMPP Sub-protocol for WebSocket
draft-ietf-xmpp-websocket-02 draft-ietf-xmpp-websocket-03
Abstract Abstract
This document defines a binding for the XMPP protocol over a This document defines a binding for the XMPP protocol over a
WebSocket transport layer. A WebSocket binding for XMPP provides WebSocket transport layer. A WebSocket binding for XMPP provides
higher performance than the current HTTP binding for XMPP. higher performance than the current HTTP binding for XMPP.
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
skipping to change at page 1, line 35 skipping to change at page 1, line 35
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on September 15, 2014. This Internet-Draft will expire on October 21, 2014.
Copyright Notice Copyright Notice
Copyright (c) 2014 IETF Trust and the persons identified as the Copyright (c) 2014 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 13 skipping to change at page 2, line 13
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 3
3. XMPP Sub-Protocol . . . . . . . . . . . . . . . . . . . . . . 3 3. XMPP Sub-Protocol . . . . . . . . . . . . . . . . . . . . . . 3
3.1. Handshake . . . . . . . . . . . . . . . . . . . . . . . . 3 3.1. Handshake . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2. Messages . . . . . . . . . . . . . . . . . . . . . . . . 4 3.2. WebSocket Messages . . . . . . . . . . . . . . . . . . . 4
3.3. XMPP Stream Setup . . . . . . . . . . . . . . . . . . . . 4 3.3. XMPP Framing . . . . . . . . . . . . . . . . . . . . . . 4
3.4. Stream Errors . . . . . . . . . . . . . . . . . . . . . . 5 3.3.1. Framed XML Stream . . . . . . . . . . . . . . . . . . 4
3.5. Closing the Connection . . . . . . . . . . . . . . . . . 5 3.3.2. Framed Stream Namespace . . . . . . . . . . . . . . . 5
3.5.1. see-other-uri . . . . . . . . . . . . . . . . . . . . 6 3.3.3. Stream Frames . . . . . . . . . . . . . . . . . . . . 5
3.6. Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 6 3.4. Stream Initiation . . . . . . . . . . . . . . . . . . . . 6
3.7. Stream Restarts . . . . . . . . . . . . . . . . . . . . . 7 3.5. Stream Errors . . . . . . . . . . . . . . . . . . . . . . 6
3.8. Pings and Keepalives . . . . . . . . . . . . . . . . . . 7 3.6. Closing the Connection . . . . . . . . . . . . . . . . . 6
3.6.1. see-other-uri . . . . . . . . . . . . . . . . . . . . 7
3.7. Stream Restarts . . . . . . . . . . . . . . . . . . . . . 8
3.8. Pings and Keepalives . . . . . . . . . . . . . . . . . . 8
3.9. Use of TLS . . . . . . . . . . . . . . . . . . . . . . . 8 3.9. Use of TLS . . . . . . . . . . . . . . . . . . . . . . . 8
3.10. Stream Management . . . . . . . . . . . . . . . . . . . . 8 3.10. Stream Management . . . . . . . . . . . . . . . . . . . . 9
4. Discovering the WebSocket Connection Method . . . . . . . . . 8 4. Discovering the WebSocket Connection Method . . . . . . . . . 9
5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9
5.1. WebSocket Subprotocol Name . . . . . . . . . . . . . . . 9 5.1. WebSocket Subprotocol Name . . . . . . . . . . . . . . . 9
5.2. URN Sub-Namespace . . . . . . . . . . . . . . . . . . . . 9 5.2. URN Sub-Namespace . . . . . . . . . . . . . . . . . . . . 10
6. Security Considerations . . . . . . . . . . . . . . . . . . . 9 6. Security Considerations . . . . . . . . . . . . . . . . . . . 10
7. References . . . . . . . . . . . . . . . . . . . . . . . . . 10 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 11
7.1. Normative References . . . . . . . . . . . . . . . . . . 10 7.1. Normative References . . . . . . . . . . . . . . . . . . 11
7.2. Informative References . . . . . . . . . . . . . . . . . 10 7.2. Informative References . . . . . . . . . . . . . . . . . 11
Appendix A. XML Schema . . . . . . . . . . . . . . . . . . . . . 11 Appendix A. XML Schema . . . . . . . . . . . . . . . . . . . . . 12
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 13 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 13
1. Introduction 1. Introduction
Applications using the Extensible Messaging and Presence Protocol Applications using the Extensible Messaging and Presence Protocol
(XMPP) (see [RFC6120] and [RFC6121]) on the Web currently make use of (XMPP) (see [RFC6120] and [RFC6121]) on the Web currently make use of
BOSH (see [XEP-0124] and [XEP-0206]), an XMPP binding to HTTP. BOSH BOSH (see [XEP-0124] and [XEP-0206]), an XMPP binding to HTTP. BOSH
is based on the HTTP long polling technique, and it suffers from high is based on the HTTP long polling technique, and it suffers from high
transport overhead compared to XMPP's native binding to TCP. In transport overhead compared to XMPP's native binding to TCP. In
addition, there are a number of other known issues with long polling addition, there are a number of other known issues with long polling
[RFC6202], which have an impact on BOSH-based systems. [RFC6202], which have an impact on BOSH-based systems.
It would be much better in most circumstances to avoid tunneling XMPP It would be much better in most circumstances to avoid tunneling XMPP
over HTTP long polled connections and instead use the XMPP protocol over HTTP long polled connections and instead use the XMPP protocol
directly. However, the APIs and sandbox that browsers have provided directly. However, the APIs and sandbox that browsers have provided
do not allow this. The WebSocket protocol [RFC6455] exists to solve do not allow this. The WebSocket protocol [RFC6455] exists to solve
these kinds of problems. The WebSocket protocol is a bidirectional these kinds of problems and is a bidirectional protocol that provides
protocol that provides a simple message-based framing layer over raw a simple message-based framing layer over raw sockets, allowing for
sockets and allows for more robust and efficient communication in web more robust and efficient communication in web applications.
applications.
The WebSocket protocol enables two-way communication between a client The WebSocket protocol enables two-way communication between a client
and a server, effectively emulating TCP at the application layer and and a server, effectively emulating TCP at the application layer and
therefore overcoming many of the problems with existing long-polling therefore overcoming many of the problems with existing long-polling
techniques for bidirectional HTTP. This document defines a WebSocket techniques for bidirectional HTTP. This document defines a WebSocket
sub-protocol for XMPP. sub-protocol for XMPP.
2. Terminology 2. Terminology
The basic unit of framing in the WebSocket protocol is called a The basic unit of framing in the WebSocket protocol is called a
message. In XMPP, the basic unit is the stanza, which is a subset of message. In XMPP, the basic unit is the stanza, which is a subset of
the first-level children of each document in an XMPP stream (see the first-level children of each document in an XMPP stream (see
Section 9 of [RFC6120]). XMPP also has a concept of messages, which Section 9 of [RFC6120]). XMPP also has a concept of messages, which
are stanzas with a top-level element of <message/>. In this are stanzas with a top-level element of <message/>. In this
document, the word "message" will mean a WebSocket message, not an document, the word "message" will mean a WebSocket message, not an
XMPP message stanza, unless otherwise noted. XMPP message stanza, unless otherwise noted.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
document are to be interpreted as described in [RFC2119]. "OPTIONAL" in this document are to be interpreted as described in
[RFC2119].
3. XMPP Sub-Protocol 3. XMPP Sub-Protocol
3.1. Handshake 3.1. Handshake
The XMPP sub-protocol is used to transport XMPP over a WebSocket The XMPP sub-protocol is used to transport XMPP over a WebSocket
connection. The client and server agree to this protocol during the connection. The client and server agree to this protocol during the
WebSocket handshake (see Section 1.3 of [RFC6455]). WebSocket handshake (see Section 1.3 of [RFC6455]).
During the WebSocket handshake, the client MUST include the |Sec- During the WebSocket handshake, the client MUST include the |Sec-
skipping to change at page 4, line 28 skipping to change at page 4, line 28
... ...
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: xmpp Sec-WebSocket-Protocol: xmpp
[WebSocket connection established] [WebSocket connection established]
C: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing" C: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing"
to="example.com" to="example.com"
version="1.0" /> version="1.0" />
3.2. Messages 3.2. WebSocket Messages
Data frame messages in the XMPP sub-protocol MUST be of the text type Data frame messages in the XMPP sub-protocol MUST be of the text type
and contain UTF-8 encoded data. The close control frame's contents and contain UTF-8 encoded data.
are specified in Section 3.5. Control frames other than close are
not restricted.
3.3. XMPP Stream Setup 3.3. XMPP Framing
The first message sent after the handshake is complete MUST be an The WebSocket XMPP sub-protocol deviates from the standard method of
<open/> element qualified by the "urn:ietf:params:xml:ns:xmpp- constructing and using XML streams as defined in [RFC6120] by
framing" namespace. The 'from', 'id', 'to', and 'version' attributes adopting the message framing provided by WebSocket to delineate the
of this element mirror those of the XMPP opening stream tag as stream open and close headers, stanzas, and other top-level stream
defined for the 'http://etherx.jabber.org/streams' namespace in XMPP elements.
[RFC6120]. The '<' character of the open tag MUST be the first
character of the text payload.
The server MUST respond with an <open /> element, or a <close /> 3.3.1. Framed XML Stream
element (see Section 3.5.1).
Clients MUST NOT attempt to multiplex XMPP streams for multiple JIDs The start of a framed XML stream is marked by the use of an opening
over the same WebSocket. "stream header" which is an <open/> element with the appropriate
attributes and namespace declarations (see Section 3.3.2). The
attributes of the <open/> element are the same as those of the
<stream/> element defined in [RFC6120], and with the same semantics.
3.4. Stream Errors The end of a framed XML stream is denoted by the closing "stream
header" which is a <close/> element with its associated attributes
and namespace declarations (see Section 3.3.2).
The introduction of the <open/> and <close/> elements is motivated by
the parsable XML document framing restriction in Section 3.3.3. As a
consequence, note that a framed XML stream does not provided a
wrapping <stream:stream/> element encompassing the entirety of the
XML stream, as in [RFC6120].
3.3.2. Framed Stream Namespace
The XML stream "headers" (the <open/> and <close/> elements) MUST be
qualified by the namespace 'urn:ietf:params:xml:ns:xmpp-framing' (the
"framed stream namespace"). If this rule is violated, the entity
that receives the offending stream header MUST close the stream with
an error, which SHOULD be <invalid-namespace> (see Section 4.9.3.10
of [RFC6120]).
3.3.3. Stream Frames
The individual frames of a framed XML stream have a one-to-one
correspondence with WebSocket messages, and MUST be parsable as
standalone XML documents, complete with all relevant namespace and
language declarations. The inclusion of XML declarations, however,
is NOT RECOMMENDED as WebSocket messages are already mandated to be
UTF-8 encoded and therefore would only add a constant size overhead
to each message.
The first character of each frame MUST be a '<' character.
Every XMPP stanza or other XML element (including the stream open and
close headers) sent directly over the XML stream MUST be sent in its
own frame.
Examples of WebSocket messages that contain independently parsable
XML documents (note that for stream features and errors, there is no
parent context element providing the "stream" namespace prefix as in
[RFC6120], and thus the stream namespace MUST be declared):
-- WS Message boundary --
<stream:features xmlns:stream="http://etherx.jabber.org/streams">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
</stream:features>
-- WS Message boundary --
<error xmlns="http://etherx.jabber.org/streams">
<host-unknown xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
</error>
-- WS Message boundary --
<message xmlns="jabber:client" xml:lang="en">
<body>Every WebSocket message is parsable by itself.</body>
</message>
3.4. Stream Initiation
The first message sent by the initiating entity after the WebSocket
opening handshake is complete MUST be an <open/> element qualified by
the "urn:ietf:params:xml:ns:xmpp-framing" namespace. The 'from',
'id', 'to', and 'version' attributes of this element mirror those of
the XMPP opening stream tag as defined for the
'http://etherx.jabber.org/streams' namespace in XMPP [RFC6120].
The receiving entity MUST respond with an <open /> element, or a
<close /> element (see Section 3.6.1).
Clients MUST NOT multiplex XMPP streams over the same WebSocket.
3.5. Stream Errors
Stream level errors in XMPP are terminal. Should such an error Stream level errors in XMPP are terminal. Should such an error
occur, the server MUST send the stream error as a complete element in occur, the server MUST send the stream error as a complete element in
a message to the client. a message to the client.
If the error occurs during the opening of a stream, the server MUST If the error occurs during the opening of a stream, the server MUST
send the initial open element response, followed by the stream level send the initial open element response, followed by the stream level
error in a second WebSocket message frame. The server MUST then error in a second WebSocket message frame. The server MUST then
close the connection as specified in Section 3.5. close the connection as specified in Section 3.6.
3.5. Closing the Connection 3.6. Closing the Connection
Either the server or the client may close the connection at any time. Either the server or the client may close the connection at any time.
Before closing the connection, the closing party SHOULD close the Before closing the connection, the closing party SHOULD close the
XMPP stream, if it has been established, by sending a message with XMPP stream, if it has been established, by sending a message with
the <close/> element, qualified by the "urn:ietf:params:xml:ns:xmpp- the <close/> element, qualified by the "urn:ietf:params:xml:ns:xmpp-
framing" namespace. The stream is considered closed when a framing" namespace. The stream is considered closed when a
corresponding <close/> element is received from the other party. corresponding <close/> element is received from the other party.
To initiate closing the WebSocket connection, the closing party MUST To close the WebSocket connection, the closing party MUST initiate
send a normal WebSocket close message with an empty body. The the WebSocket closing handshake (see Section 7.1.2 of [RFC6455]).
connection is considered closed when a matching close message is
received (see Section 1.4 of [RFC6455]).
An example of ending an XMPP over WebSocket session by first closing An example of ending an XMPP over WebSocket session by first closing
the XMPP stream layer and then the WebSocket connection layer: the XMPP stream layer and then the WebSocket connection layer:
Client (XMPP WSS) Server Client (XMPP WSS) Server
| | | | | | | |
| | <close xmlns="urn:ietf:params:xml:ns:xmpp-framing /> | | | | <close xmlns="urn:ietf:params:xml:ns:xmpp-framing /> | |
| |------------------------------------------------------------>| | | |------------------------------------------------------------>| |
| | <close xmlns="urn:ietf:params:xml:ns:xmpp-framing" /> | | | | <close xmlns="urn:ietf:params:xml:ns:xmpp-framing" /> | |
| |<------------------------------------------------------------| | | |<------------------------------------------------------------| |
skipping to change at page 6, line 11 skipping to change at page 7, line 35
If a client closes the WebSocket connection without closing the XMPP If a client closes the WebSocket connection without closing the XMPP
stream after having enabled stream management (see Section 3.10), the stream after having enabled stream management (see Section 3.10), the
server SHOULD keep the XMPP session alive for a period of time based server SHOULD keep the XMPP session alive for a period of time based
on server policy, as specified in [XEP-0198]. If the client has not on server policy, as specified in [XEP-0198]. If the client has not
negotiated the use of [XEP-0198], there is no distinction between a negotiated the use of [XEP-0198], there is no distinction between a
stream that was closed as described above and a simple disconnection; stream that was closed as described above and a simple disconnection;
the stream is then considered implicitly closed and the XMPP session the stream is then considered implicitly closed and the XMPP session
ended. ended.
3.5.1. see-other-uri 3.6.1. see-other-uri
If the server (or a connection mananger intermediary) wishes to If the server (or a connection manager intermediary) wishes to
instruct the client to move to a different WebSocket endpoint (e.g. instruct the client to move to a different WebSocket endpoint (e.g.
for load balancing purposes), the server MAY send a <close/> element for load balancing purposes), the server MAY send a <close/> element
and set the "see-other-uri" attribute to the URI of the new WebSocket and set the "see-other-uri" attribute to the URI of the new
endpoint. connection endpoint (which MAY be for a different transport method,
such as BOSH (see [XEP-0124] and [XEP-0206]).
Clients MUST NOT accept suggested endpoints with a lower security Clients MUST NOT accept suggested endpoints with a lower security
context (e.g. moving from a "wss://" endpoint to a "ws://" endpoint). context (e.g. moving from a "wss://" endpoint to a "ws://" or "http:/
/" endpoint).
An example of the server closing a stream and instructing the client An example of the server closing a stream and instructing the client
to connect at a different WebSocket endpoint: to connect at a different WebSocket endpoint:
S: <close xmlns="urn:ietf:params:xml:ns:xmpp-framing" S: <close xmlns="urn:ietf:params:xml:ns:xmpp-framing"
see-other-uri="wss://otherendpoint.example/xmpp-bind" /> see-other-uri="wss://otherendpoint.example/xmpp-bind" />
3.6. Stanzas
Every XMPP stanza or other XML element sent directly over the XMPP
stream (e.g. <features xmlns="http://etherx.jabber.org/streams"/>)
MUST be sent in its own message. As such, every WebSocket text
message that is received MUST be a complete and parsable XML
fragment, with all relevant xmlns and xml:lang declarations
specified.
As it is already mandated that the content of each message is UTF-8
encoded, XML text declarations SHOULD NOT be included in messages.
Examples of WebSocket messages that contain independently parsable
XML fragments (note that for stream features and errors, there is no
parent context element providing the "stream" namespace prefix as in
[RFC6120], and thus the stream namespace MUST be declared):
<features xmlns="http://etherx.jabber.org/streams">
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
</features>
<error xmlns="http://etherx.jabber.org/streams">
<host-unknown xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
</error>
<message xmlns="jabber:client" xml:lang="en">
<body>Every WebSocket message is parsable by itself.</body>
</message>
3.7. Stream Restarts 3.7. Stream Restarts
After successful SASL authentication, an XMPP stream needs to be Whenever a stream restart is mandated, both the server and client
restarted. In these cases, as soon as the message is sent (or streams are implicitly closed and new streams MUST be opened, using
received) containing the success indication, both the server and the same process as in Section 3.4. The client MUST send a new
client streams are implicitly closed, and new streams need to be stream <open/> element and MUST NOT send a closing <close/> element.
opened. The client MUST open a new stream as in Section 3.3 and MUST
NOT send a closing <close/> element. An example of restarting the stream after successful SASL
negotiation:
S: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" /> S: <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />
[Streams implicitly closed] [Streams implicitly closed]
C: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing" C: <open xmlns="urn:ietf:params:xml:ns:xmpp-framing"
to="example.com" to="example.com"
version="1.0" /> version="1.0" />
3.8. Pings and Keepalives 3.8. Pings and Keepalives
skipping to change at page 13, line 20 skipping to change at page 13, line 46
Email: lance@andyet.net Email: lance@andyet.net
Jack Moffitt Jack Moffitt
Mozilla Mozilla
Email: jack@metajack.im Email: jack@metajack.im
Eric Cestari Eric Cestari
cstar industries cstar industries
Email: eric@cestari.info Email: eric@cstar.io
 End of changes. 26 change blocks. 
89 lines changed or deleted 129 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/