No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0206.xml 20KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>XMPP Over BOSH</title>
  10. <abstract>This specification defines how the Bidirectional-streams Over Synchronous HTTP (BOSH) technology can be used to transport XMPP stanzas. The result is an HTTP binding for XMPP communications that is useful in situations where a device or client is unable to maintain a long-lived TCP connection to an XMPP server.</abstract>
  12. <number>0206</number>
  13. <status>Draft</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0124</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>xbosh</shortname>
  24. <schemaloc>
  25. <url></url>
  26. </schemaloc>
  27. &ianpaterson;
  28. &stpeter;
  29. &lance;
  30. &winfried;
  31. <revision>
  32. <version>1.4</version>
  33. <date>2014-04-09</date>
  34. <initials>ls/wt</initials>
  35. <remark><p>Incorporated patches from community review.</p></remark>
  36. </revision>
  37. <revision>
  38. <version>1.3</version>
  39. <date>2010-07-02</date>
  40. <initials>psa</initials>
  41. <remark><p>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.</p></remark>
  42. </revision>
  43. <revision>
  44. <version>1.2</version>
  45. <date>2008-10-29</date>
  46. <initials>psa</initials>
  47. <remark><p>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.</p></remark>
  48. </revision>
  49. <revision>
  50. <version>1.1</version>
  51. <date>2007-06-04</date>
  52. <initials>ip</initials>
  53. <remark><p>remote-stream-error includes full &lt;stream:error/&gt; element (not just its content) and optional stanzas</p></remark>
  54. </revision>
  55. <revision>
  56. <version>1.0</version>
  57. <date>2007-02-28</date>
  58. <initials>ip</initials>
  59. <remark><p>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.</p></remark>
  60. </revision>
  61. </header>
  62. <section1 topic='Introduction' anchor='intro'>
  63. <p>The &xep0124; 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 &xmppcore;) to be bound to HTTP.</p>
  64. </section1>
  65. <section1 topic="&lt;body/&gt; Wrapper Element" anchor='wrapper'>
  66. <p>If the BOSH &lt;body/&gt; wrapper is not empty, then it SHOULD contain one of the following:</p>
  67. <ul>
  68. <li>A complete &lt;stream:features/&gt; element (in which case the BOSH &lt;body/&gt; element MUST include the namespace xmlns:stream='').</li>
  69. <li>A complete element used for SASL negotiation and qualified by the 'urn:ietf:params:xml:ns:xmpp-sasl' namespace.</li>
  70. <li>One or more complete &lt;message/&gt;, &lt;presence/&gt;, and/or &lt;iq/&gt; elements qualified by the 'jabber:client' namespace.</li>
  71. <li>A &lt;stream:error/&gt; element (in which case the BOSH &lt;body/&gt; element MUST include the namespace xmlns:stream='' and it MUST feature the 'remote-stream-error' terminal error condition), preceded by zero or more complete &lt;message/&gt;, &lt;presence/&gt;, and/or &lt;iq/&gt; elements qualified by the 'jabber:client' namespace.</li>
  72. </ul>
  73. <p>Note: Many existing XMPP-specific implementations of BOSH clients and connection managers do not specify the namespace of &lt;message/&gt;, &lt;presence/&gt;, or &lt;iq/&gt; elements, since that allows them to forward stanzas without modification (the XMPP &lt;stream:stream/&gt; 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 '' namespace.</p>
  74. <p>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.</p>
  75. </section1>
  76. <section1 topic="Session Creation Request" anchor='initiate'>
  77. <p>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 &lt;stream:stream/&gt; element as defined in &rfc6120;. The connection manager SHOULD forward the value to the XMPP server accordingly.</p>
  78. <example caption="Requesting a session with a version attribute">
  79. <![CDATA[POST /webclient HTTP/1.1
  80. Host:
  81. Accept-Encoding: gzip, deflate
  82. Content-Type: text/xml; charset=utf-8
  83. Content-Length: 104
  84. <body content='text/xml; charset=utf-8'
  85. from=''
  86. hold='1'
  87. rid='1573741820'
  88. to=''
  89. route=''
  90. wait='60'
  91. xml:lang='en'
  92. xmpp:version='1.0'
  93. xmlns=''
  94. xmlns:xmpp='urn:xmpp:xbosh'/>]]></example>
  95. <p>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.</p>
  96. <p>Note: Unlike the protocol defined in &xep0025;, an opening &lt;stream:stream&gt; tag is not sent to the connection manager (since BOSH &lt;body/&gt; 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).</p>
  97. </section1>
  98. <section1 topic="Session Creation Response" anchor='create'>
  99. <p>The connection manager SHOULD include a 'version' attribute (qualified by the 'urn:xmpp:xbosh' namespace) and a &lt;stream:features/&gt; element (qualified by the '' 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.</p>
  100. <p>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" &BOOLEANNOTE;. 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.</p>
  101. <p>Note: The same procedure applies to the <em>obsolete</em> XMPP-specific 'authid' attribute of the BOSH &lt;body/&gt; 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 <em>obsolete</em>&#32;&xep0078; protocol. <note>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).</note></p>
  102. <example caption="Session creation response with stream features">
  103. <![CDATA[HTTP/1.1 200 OK
  104. Content-Type: text/xml; charset=utf-8
  105. Content-Length: 674
  106. <body wait='60'
  107. inactivity='30'
  108. polling='5'
  109. requests='2'
  110. hold='1'
  111. from=''
  112. accept='deflate,gzip'
  113. sid='SomeSID'
  114. charsets='ISO_8859-1 ISO-2022-JP'
  115. xmpp:restartlogic='true'
  116. xmpp:version='1.0'
  117. authid='ServerStreamID'
  118. xmlns=''
  119. xmlns:xmpp='urn:xmpp:xbosh'
  120. xmlns:stream=''>
  121. <stream:features>
  122. <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
  123. <mechanism>SCRAM-SHA-1</mechanism>
  124. <mechanism>PLAIN</mechanism>
  125. </mechanisms>
  126. </stream:features>
  127. </body>
  128. ]]></example>
  129. <p>If no &lt;stream:features/&gt; 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 &lt;stream:features/&gt; element.</p>
  130. <example caption="Subsequent response with stream features">
  131. <![CDATA[HTTP/1.1 200 OK
  132. Content-Type: text/xml; charset=utf-8
  133. Content-Length: 483
  134. <body xmpp:version='1.0'
  135. authid='ServerStreamID'
  136. xmlns=''
  137. xmlns:xmpp='urn:xmpp:xbosh'
  138. xmlns:stream=''>
  139. <stream:features>
  140. <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
  141. <mechanism>SCRAM-SHA-1</mechanism>
  142. <mechanism>PLAIN</mechanism>
  143. </mechanisms>
  144. </stream:features>
  145. </body>
  146. ]]></example>
  147. <p>Note: The client SHOULD ignore any Transport Layer Security (TLS) feature since BOSH channel encryption SHOULD be negotiated at the HTTP layer.</p>
  148. <p>TLS compression (as defined in &rfc6120;) and Stream Compression (as defined in &xep0138;) 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.</p>
  149. <p>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.</p>
  150. </section1>
  151. <section1 topic="Authentication and Resource Binding" anchor='preconditions-sasl'>
  152. <p>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 &rfc6120;. 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.</p>
  153. <example caption="SASL authentication step 1">
  154. <![CDATA[POST /webclient HTTP/1.1
  155. Host:
  156. Accept-Encoding: gzip, deflate
  157. Content-Type: text/xml; charset=utf-8
  158. Content-Length: 231
  159. <body rid='1573741821'
  160. sid='SomeSID'
  161. xmlns=''>
  162. <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
  163. mechanism='SCRAM-SHA-1'>
  165. </auth>
  166. </body>
  167. ]]></example>
  168. <example caption="SASL authentication step 2">
  169. <![CDATA[HTTP/1.1 200 OK
  170. Content-Type: text/xml; charset=utf-8
  171. Content-Length: 294
  172. <body xmlns=''>
  173. <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
  176. AwTmpkbUxUa3hNbVV0TkRsbU5UTm1ORE5rTURNeixpPTQwOTY=
  177. </challenge>
  178. </body>
  179. ]]></example>
  180. <example caption="SASL authentication step 3">
  181. <![CDATA[POST /webclient HTTP/1.1
  182. Host:
  183. Accept-Encoding: gzip, deflate
  184. Content-Type: text/xml; charset=utf-8
  185. Content-Length: 295
  186. <body rid='1573741822'
  187. sid='SomeSID'
  188. xmlns=''>
  189. <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
  192. RCa0gyRlhzMFdEWHZKWXc9
  193. </response>
  194. </body>
  195. ]]></example>
  196. <example caption="SASL authentication step 4">
  197. <![CDATA[HTTP/1.1 200 OK
  198. Content-Type: text/xml; charset=utf-8
  199. Content-Length: 149
  200. <body xmlns=''>
  201. <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
  202. dj1wTk5ERlZFUXh1WHhDb1NFaVc4R0VaKzFSU289
  203. </success>
  204. </body>
  205. ]]></example>
  206. <p>Upon receiving the &lt;success/&gt; element, the client MUST then ask the connection manager to restart the stream by sending a "restart request" that is structured as follows:</p>
  207. <ul>
  208. <li>The BOSH &lt;body/&gt; element MUST include a boolean 'restart' attribute (qualified by the 'urn:xmpp:xbosh' namespace) whose value is set to "true" &BOOLEANNOTE;.</li>
  209. <li>The BOSH &lt;body/&gt; element SHOULD include the 'to' attribute.</li>
  210. <li>The BOSH &lt;body/&gt; element SHOULD include the 'xml:lang' attribute.</li>
  211. <li>The BOSH &lt;body/&gt; element SHOULD be empty (i.e., not contain an XML stanza). However, if the client includes an XML stanza in the body, the connection manager SHOULD ignore it. <note>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.</note></li>
  212. </ul>
  213. <p>When SASL-EXTERNAL is used in combination with BOSH the BOSH &lt;body/&gt; 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.</p>
  214. <p>The following example illustrates the format for a restart request.</p>
  215. <example caption="Restart request">
  216. <![CDATA[POST /webclient HTTP/1.1
  217. Content-Type: text/xml; charset=utf-8
  218. Content-Length: 240
  219. <body rid='1573741824'
  220. sid='SomeSID'
  221. to=''
  222. xml:lang='en'
  223. xmpp:restart='true'
  224. xmlns=''
  225. xmlns:xmpp='urn:xmpp:xbosh'/>
  226. ]]></example>
  227. <p>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 &lt;stream:stream&gt; tag over the same TCP connection to the XMPP server. If the connection manager receives a &lt;stream:features/&gt; element from the XMPP server, it MUST forward that element to the client:</p>
  228. <example caption="Result of restart request">
  229. <![CDATA[HTTP/1.1 200 OK
  230. Content-Type: text/xml; charset=utf-8
  231. Content-Length: 221
  232. <body xmlns=''
  233. xmlns:stream=''>
  234. <stream:features>
  235. <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
  236. </stream:features>
  237. </body>
  238. ]]></example>
  239. <p>The client can then complete any mandatory or discretionary stream feature negotiations.</p>
  240. <example caption="Resource binding request">
  241. <![CDATA[POST /webclient HTTP/1.1
  242. Content-Type: text/xml; charset=utf-8
  243. Content-Length: 240
  244. <body rid='1573741825'
  245. sid='SomeSID'
  246. xmlns=''>
  247. <iq id='bind_1'
  248. type='set'
  249. xmlns='jabber:client'>
  250. <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
  251. <resource>httpclient</resource>
  252. </bind>
  253. </iq>
  254. </body>
  255. ]]></example>
  256. <example caption="Resource binding result">
  257. <![CDATA[HTTP/1.1 200 OK
  258. Content-Type: text/xml; charset=utf-8
  259. Content-Length: 221
  260. <body xmlns=''>
  261. <iq id='bind_1'
  262. type='result'
  263. xmlns='jabber:client'>
  264. <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
  265. <jid></jid>
  266. </bind>
  267. </iq>
  268. </body>
  269. ]]></example>
  270. </section1>
  271. <section1 topic='remote-stream-error' anchor='remote-stream-error'>
  272. <p>The content of the &lt;body/&gt; element is zero or more stanzas followed by a copy of the &lt;stream:error/&gt; element <note>Earlier obsolete versions of this protocol specified that the &lt;body/&gt; element should contain only the <em>content</em> of the &lt;stream:error/&gt; element.</note> (qualified by the '' namespace) received from the XMPP server:</p>
  273. <example caption="Remote error">
  274. <![CDATA[HTTP/1.1 200 OK
  275. Content-Type: text/xml; charset=utf-8
  276. Content-Length: 68
  277. <body condition='remote-stream-error'
  278. type='terminate'
  279. xmlns=''
  280. xmlns:stream=''>
  281. <message from=''
  282. to=''
  283. xmlns='jabber:client'>
  284. <body>I said "Hi!"</body>
  285. </message>
  286. <stream:error>
  287. <xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
  288. <text xmlns='urn:ietf:params:xml:ns:xmpp-streams'
  289. xml:lang='en'>
  290. Some special application diagnostic information!
  291. </text>
  292. <escape-your-data xmlns='application-ns'/>
  293. </stream:error>
  294. </body>
  295. ]]></example>
  296. </section1>
  297. <section1 topic='recipient-unavailable' anchor='recipient-unavailable'>
  298. <p>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 &rfc6121;</p>
  299. <ol>
  300. <li>If the delivered stanza was &PRESENCE;, silently drop the stanza and do not return an error to the sender.</li>
  301. <li>If the delivered stanza was &IQ;, return a &unavailable; error to the sender.</li>
  302. <li>If the delivered stanza was &MESSAGE;, return a &recipient; error to the sender.</li>
  303. </ol>
  304. <p>When an XMPP server receives a &MESSAGE; stanza of type "error" containing a &recipient; condition from a connection manager, it SHOULD store the message for later delivery if offline storage is enabled (see &xep0160;), otherwise route the error stanza to the sender.</p>
  305. </section1>
  306. <section1 topic='Security Considerations' anchor='security'>
  307. <p>This protocol does not introduce any new security considerations beyond those specified in <cite>BOSH</cite> and <cite>XMPP Core</cite>.</p>
  308. </section1>
  309. <section1 topic='IANA Considerations' anchor='iana'>
  310. <p>This document requires no interaction with &IANA;.</p>
  311. </section1>
  312. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  313. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  314. <p>The &REGISTRAR; includes 'urn:xmpp:xbosh' in its registry of protocol namespaces.</p>
  315. </section2>
  316. </section1>
  317. <section1 topic='XML Schema' anchor='schema'>
  318. <code><![CDATA[
  319. <?xml version='1.0' encoding='UTF-8'?>
  320. <xs:schema
  321. xmlns:xs=''
  322. targetNamespace='urn:xmpp:xbosh'
  323. xmlns='urn:xmpp:xbosh'
  324. attributeFormDefault='qualified'
  325. elementFormDefault='qualified'>
  326. <xs:annotation>
  327. <xs:documentation>
  328. The protocol documented by this schema is defined in
  329. XEP-0206:
  330. </xs:documentation>
  331. </xs:annotation>
  332. <xs:attribute name='restart'
  333. type='xs:boolean'
  334. default='false'/>
  335. <xs:attribute name='restartlogic'
  336. type='xs:boolean'
  337. default='false'/>
  338. <xs:attribute name='version'
  339. type='xs:string'
  340. default='1.0'/>
  341. </xs:schema>
  342. ]]></code>
  343. </section1>
  344. <section1 topic='Acknowledgements' anchor='ack'>
  345. <p>Thanks to Dave Cridland, Steffen Larsen, Matt Miller, Jack Moffitt, Stefan Strigler, Mike Taylor, Winfried Tilanus, Ashley Ward, and Matthew Wild for their feedback.</p>
  346. <p>Thanks to Kevin Winters for his assistance with the schema.</p>
  347. </section1>
  348. </xep>