idnits 2.17.1 draft-moffitt-xmpp-over-websocket-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (June 25, 2012) is 4316 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) No issues found here. Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 HyBi Working Group J. Moffitt, Ed. 3 Internet-Draft 4 Intended status: Standards Track E. Cestari 5 Expires: December 27, 2012 ProcessOne 6 June 25, 2012 8 An XMPP Sub-protocol for WebSocket 9 draft-moffitt-xmpp-over-websocket-01 11 Abstract 13 This document defines a binding for the XMPP protocol over a 14 WebSocket transport layer. A WebSocket binding for XMPP provides 15 higher performance than the current HTTP binding for XMPP. 17 Status of this Memo 19 This Internet-Draft is submitted in full conformance with the 20 provisions of BCP 78 and BCP 79. 22 Internet-Drafts are working documents of the Internet Engineering 23 Task Force (IETF). Note that other groups may also distribute 24 working documents as Internet-Drafts. The list of current Internet- 25 Drafts is at http://datatracker.ietf.org/drafts/current/. 27 Internet-Drafts are draft documents valid for a maximum of six months 28 and may be updated, replaced, or obsoleted by other documents at any 29 time. It is inappropriate to use Internet-Drafts as reference 30 material or to cite them other than as "work in progress." 32 This Internet-Draft will expire on December 27, 2012. 34 Copyright Notice 36 Copyright (c) 2012 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents 41 (http://trustee.ietf.org/license-info) in effect on the date of 42 publication of this document. Please review these documents 43 carefully, as they describe your rights and restrictions with respect 44 to this document. Code Components extracted from this document must 45 include Simplified BSD License text as described in Section 4.e of 46 the Trust Legal Provisions and are provided without warranty as 47 described in the Simplified BSD License. 49 Table of Contents 51 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 52 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 53 3. XMPP Sub-Protocol . . . . . . . . . . . . . . . . . . . . . . 5 54 3.1. Handshake . . . . . . . . . . . . . . . . . . . . . . . . 5 55 3.2. Messages . . . . . . . . . . . . . . . . . . . . . . . . . 5 56 3.3. XMPP Stream Setup . . . . . . . . . . . . . . . . . . . . 5 57 3.4. Stream Errors . . . . . . . . . . . . . . . . . . . . . . 6 58 3.5. Closing the Connection . . . . . . . . . . . . . . . . . . 6 59 3.6. Stanzas . . . . . . . . . . . . . . . . . . . . . . . . . 6 60 3.7. Stream Restarts . . . . . . . . . . . . . . . . . . . . . 6 61 3.8. Pings and Keepalives . . . . . . . . . . . . . . . . . . . 6 62 3.9. TLS . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 4. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 64 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 65 6. Security Considerations . . . . . . . . . . . . . . . . . . . 10 66 7. Informative References . . . . . . . . . . . . . . . . . . . . 11 67 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 12 69 1. Introduction 71 Applications using XMPP (see [RFC6120] and [RFC6121]) on the Web 72 currently make use of BOSH (see [XEP-0124] and [XEP-0206]), an XMPP 73 binding to HTTP. BOSH is based on the HTTP long polling technique, 74 and it suffers from high transport overhead compared to XMPP's native 75 binding to TCP. 77 It would be much better in most circumstances to avoid tunneling XMPP 78 over HTTP long polled connections and instead use the XMPP protocol 79 directly. However, the APIs and sandbox that browsers have provided 80 do not allow this. The WebSocket protocol [RFC6455] now exists to 81 solve these kinds of problems. The WebSocket protocol is a bi- 82 directional protocol that provides a simple message-based framing 83 layer over raw sockets and allows for more robust and efficient 84 communication in web applications. 86 This document defines a binding of the XMPP protocol over the 87 WebSocket protocol transport. It makes using XMPP within web 88 applications simpler and more efficient. 90 2. Terminology 92 The basic unit of framing in the WebSocket protocol is called a 93 message. In XMPP, the basic unit is the stanza, which is a subset of 94 the first-level children of each document in an XMPP stream (see 95 Section 9 of [RFC6120]). XMPP also has a concept of messages, which 96 are stanzas whose top-level element name is message. In this 97 document, the word "message" will mean a WebSocket message, not an 98 XMPP message stanza (see Section 3.2). 100 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 101 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 102 document are to be interpreted as described in [RFC2119]. 104 3. XMPP Sub-Protocol 106 3.1. Handshake 108 The xmpp sub-protocol is used to transport XMPP over a WebSocket 109 connection. The client and server agree to this protocol during the 110 WebSocket handshake (see Section 1.3 of [RFC6455]). 112 During the WebSocket handshake, the client MUST include the |Sec- 113 WebSocket-Protocol| header in its handshake, and the value |xmpp| 114 must be included in the list of protocols. The reply from the server 115 MUST also contain |xmpp| in its own |Sec-WebSocket-Protocol| header 116 in order for an XMPP sub-protocol connection to be established. 118 Once the handshake is complete, WebSocket messages sent or received 119 will conform to the protocol defined in the rest of this document. 121 3.2. Messages 123 Data frame messages in the XMPP sub-protocol MUST be of the text type 124 and contain UTF-8 encoded data. The close control frame's contents 125 are specified in Section 3.5. Control frames other than close are 126 not restricted. 128 Unless noted in text, the word "message" will mean a WebSocket 129 message containing a text data frame. 131 3.3. XMPP Stream Setup 133 The first message sent after the handshake is complete MUST be an 134 XMPP opening stream tag as defined in XMPP [RFC6120] or an XML text 135 declaration (see Section 4.3.1 of [W3C.REC-xml-20081126]) followed by 136 an XMPP opening stream tag. The stream tag MUST NOT be closed (i.e. 137 the closing tag should not appear in the message) as 138 it is the start of the client's outgoing XML. The '<' character of 139 the tag or text declaration MUST be the first character of the text 140 payload. 142 The server MUST respond with a message containing an error (see 143 Section 3.4), its own opening stream tag, or an XML text declaration 144 followed by an opening stream tag. 146 Except in the case of certain stream errors (see Section 3.4), the 147 opening stream tag, , MUST appear in a message by 148 itself. 150 3.4. Stream Errors 152 Stream level errors in XMPP are terminal. Should such an error 153 occur, the server MUST send the stream error as a complete element in 154 a message to the client. 156 If the error occurs during the opening of a stream, the stream error 157 message MUST start with an opening stream tag (see Section 4.7.1 of 158 [RFC6120]) and end with a closing stream tag. 160 After the stream error and closing stream tag have been sent, the 161 server MUST close the connection as in Section 3.5. 163 3.5. Closing the Connection 165 Either the server or the client may close the connection at any time. 166 Before closing the connection, the closing party MUST close the XMPP 167 stream if it has been established. To initiate the close, the 168 closing party MUST send a normal WebSocket close message with an 169 empty body. The connection is considered closed when a matching 170 close message is received (see Section 1.4 of [RFC6455]). 172 Except in the case of certain stream errors (see Section 3.4), the 173 closing stream tag, , MUST appear in a message by 174 itself. 176 3.6. Stanzas 178 Each XMPP stanza MUST be sent in its own message. A stanza MUST NOT 179 be split over multiple messages. All first level children of the 180 element MUST be treated the same as stanzas (e.g. 181 and ). 183 3.7. Stream Restarts 185 After successful SASL authentication, an XMPP stream must be 186 restarted. In these cases, as soon as the message is sent (or 187 received) containing the success indication, both the server and 188 client streams are implicitly closed, and new streams must be opened. 189 The client MUST open a new stream as in Section 3.3 and MUST NOT send 190 a closing stream tag. 192 3.8. Pings and Keepalives 194 XMPP servers send whitespace pings as keepalives between stanzas, and 195 XMPP clients can do the same thing. These extra whitespace 196 characters are not significant in the protocol. Servers and clients 197 SHOULD use WebSocket ping messages instead for this purpose. 199 The XMPP Ping extension [XEP-0199] allows entities to send and 200 respond to ping requests. A client sending a WebSocket ping is 201 equivalent to pinging the WebSocket server, which may also be the 202 XMPP server. When the XMPP server is not also the WebSocket server, 203 a WebSocket ping may be useful to check the health of the 204 intermediary server. 206 3.9. TLS 208 TLS cannot be used in The XMPP sub-protocol because the sub-protocol 209 does not allow for raw binary data to be sent. A server MUST NOT 210 advertise TLS as a stream feature (see Section 4.6 of [RFC6120]). A 211 client MUST ignore the TLS feature if it is advertised over 212 WebSocket. 214 4. Examples 216 Examples will be added as soon as the WebSocket protocol 217 specification is more stable. 219 5. IANA Considerations 221 If a registry is created for WebSocket sub-protocols, the xmpp sub- 222 protocol will be registered. 224 6. Security Considerations 226 Since application level TLS cannot be used (see Section 3.9), 227 applications which need to protect the privacy of the XMPP traffic 228 need to do so a the WebSocket level or some other higher level. 230 7. Informative References 232 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 233 Requirement Levels", BCP 14, RFC 2119, March 1997. 235 [RFC6120] Saint-Andre, P., "Extensible Messaging and Presence 236 Protocol (XMPP): Core", RFC 6120, March 2011. 238 [RFC6121] Saint-Andre, P., "Extensible Messaging and Presence 239 Protocol (XMPP): Instant Messaging and Presence", 240 RFC 6121, March 2011. 242 [RFC6455] Fette, I. and A. Melnikov, "The WebSocket Protocol", 243 RFC 6455, December 2011. 245 [W3C.REC-xml-20081126] 246 Sperberg-McQueen, C., Yergeau, F., Maler, E., Paoli, J., 247 and T. Bray, "Extensible Markup Language (XML) 1.0 (Fifth 248 Edition)", World Wide Web Consortium Recommendation REC- 249 xml-20081126, November 2008, 250 . 252 [XEP-0124] 253 Paterson, I., Smith, D., Saint-Andre, P., and J. Moffitt, 254 "Bidirectional-streams Over Synchronous HTTP (BOSH)", XSF 255 XEP 0124, July 2010. 257 [XEP-0199] 258 Saint-Andre, P., "XMPP Ping", XSF XEP 0199, June 2009. 260 [XEP-0206] 261 Paterson, I. and P. Saint-Andre, "XMPP Over BOSH", XSF 262 XEP 0206, July 2010. 264 Authors' Addresses 266 Jack Moffitt (editor) 268 Email: jack@metajack.im 270 Eric Cestari 271 ProcessOne 273 Email: ecestari@process-one.com