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-0207.xml 22KB

  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 Eventing via Pubsub</title>
  10. <abstract>This document specifies semantics for using the XMPP publish-subscribe protocol to handle generic XMPP events (including presence, one-to-one messaging, and groupchat).</abstract>
  12. <number>0207</number>
  13. <status>Active</status>
  14. <type>Humorous</type>
  15. <sig>Standards JIG</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0060</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>N/A</shortname>
  24. &stpeter;
  25. <revision>
  26. <version>1.0</version>
  27. <date>2007-04-01</date>
  28. <initials>psa</initials>
  29. <remark><p>April Fools!</p></remark>
  30. </revision>
  31. </header>
  32. <section1 topic='Introduction' anchor='intro'>
  33. <p>&xep0163; (PEP) introduced the concept of "eventing" into the Extensible Messaging and Presence Protocol (see &xmppcore;). But PEP merely scratched the surface of eventing technologies based on the XMPP &xep0060; extension. This document extends the eventing concept to its ultimate conclusion: the ability to communicate all XMPP semantics via pubsub.</p>
  34. </section1>
  35. <section1 topic='Concepts and Approach' anchor='approach'>
  36. <p>Jabber technologies as invented by Jeremie Miller started out as a relatively lightweight XML messaging transport, but they have become unnecessarily -- even ridiculously -- bloated over the years. Formalization of the core Jabber protocols as the Extensible Messaging and Presence Protocol (XMPP) within the IETF seemed like a good idea at the time, but the extensible nature of the core protocols has tempted the developer community to extend XMPP six ways from Sunday. The result has been a plethora of different conceptual models for various extensions, such as &xep0045; for multi-user communication and &xep0050; for structured entity-to-entity request/response semantics. These different models are inelegant and unnecessary. Indeed, even the inclusion of three different basic packet types (presence, message, and IQ) in the core protocol is overkill.</p>
  37. <p>We can do better. In fact, we can reduce all the communication types and styles that are currently defined within the XMPP ecosystem to one model: publish-subscribe as specified in <cite>XEP-0060</cite>.</p>
  38. <p>Consider:</p>
  39. <ul>
  40. <li>It has often been observed that presence (see &xmppim;) is a form of publish-subscribe. <note>See, for instance, &lt;<link url=''></link>&gt;.</note></li>
  41. <li>The primitive XMPP "roster" can be easily implemented using the pubsub permissions model.</li>
  42. <li>Multi-user chat too is a kind of publish-subscribe, since a single "publish" to the room results in multiple notifications to the room occupants, who are really subscribers to an information node.</li>
  43. <li>Even one-to-one messaging is just another example of publish-subscribe (in fact it is a special case of multi-user chat).</li>
  44. </ul>
  45. <p>The remainder of this document will prove beyond a doubt that the older, multiple approaches are obsolete, and that there is indeed one model that serves all our needs: pubsub.</p>
  46. </section1>
  47. <section1 topic='Presence' anchor='presence'>
  48. <p>Presence simply is pubsub, since it follows the classic "observer" pattern: multiple subscribers receive notifications whenever the publisher (typically an end user) generates an event related to network availability. Currently in XMPP this is done with the &PRESENCE; stanza, which serves as a kind of pubsub primitive (though only for availability information). For example, Juliet may log into the capulet.lit server and send presence:</p>
  49. <example caption='Presence Update'><![CDATA[
  50. <presence from='juliet@capulet.lit/balcony'>
  51. <status>Moping</status>
  52. </presence>
  53. ]]></example>
  54. <p>The capulet.lit server will then send notifications to all of the users who have subscribed to Juliet's presence:</p>
  55. <example caption='Presence Notifications'><![CDATA[
  56. <presence from='juliet@capulet.lit/balcony' to='romeo@montague.lit/mobile'>
  57. <status>Moping</status>
  58. </presence>
  59. <presence from='juliet@capulet.lit/balcony' to='nurse@capulet.lit/chamber'>
  60. <status>Moping</status>
  61. </presence>
  62. <presence from='juliet@capulet.lit/balcony' to='benvolio@montague.lit/pda'>
  63. <status>Moping</status>
  64. </presence>
  65. [etc.]
  66. ]]></example>
  67. <p>But the same functionality can be implemented more elegantly using pubsub:</p>
  68. <example caption='Presence Publish'><![CDATA[
  69. <iq from='juliet@capulet.lit/balcony' type='set' id='pres1'>
  70. <pubsub xmlns=''>
  71. <publish node='presence'>
  72. <item>
  73. <presence from='juliet@capulet.lit/balcony' xmlns='jabber:client'>
  74. <status>Moping</status>
  75. </presence>
  76. </item>
  77. </publish>
  78. </pubsub>
  79. </iq>
  80. <iq to='juliet@capulet.lit/balcony' type='result' id='pres1'/>
  81. ]]></example>
  82. <p>The server (here implementing PEP) then sends notifications to the subscribers:</p>
  83. <example caption='Presence Notifications via Pubsub'><![CDATA[
  84. <message from='juliet@capulet.lit'
  85. to='romeo@montague.lit/mobile'
  86. id='presfoo'>
  87. <event xmlns=''>
  88. <items node='presence'>
  89. <item>
  90. <presence from='juliet@capulet.lit/balcony' xmlns='jabber:client'>
  91. <status>Moping</status>
  92. </presence>
  93. </item>
  94. </items>
  95. </event>
  96. </message>
  97. <message from='juliet@capulet.lit'
  98. to='nurse@capulet.lit/chamber'
  99. id='presfoo'>
  100. <event xmlns=''>
  101. <items node='presence'>
  102. <item>
  103. <presence from='juliet@capulet.lit/balcony' xmlns='jabber:client'>
  104. <status>Moping</status>
  105. </presence>
  106. </item>
  107. </items>
  108. </event>
  109. </message>
  110. <message from='juliet@capulet.lit'
  111. to='benvolio@montague.lit/pda'
  112. id='presfoo'>
  113. <event xmlns=''>
  114. <items node='presence'>
  115. <item>
  116. <presence from='juliet@capulet.lit/balcony' xmlns='jabber:client'>
  117. <status>Moping</status>
  118. </presence>
  119. </item>
  120. </items>
  121. </event>
  122. </message>
  123. ]]></example>
  124. <p>It is true that in this case the packets are significantly larger in the pubsub realization than in the old-fashioned presence realization. This is the price of elegance. Implementations SHOULD use native Transport Layer Security compression (see &rfc5246;) or &xep0138; at the application layer to conserve bandwidth.</p>
  125. </section1>
  126. <section1 topic='Rosters and Presence Subscriptions' anchor='roster'>
  127. <p>The original Jabber technologies included a kind of Buddy List &#8482; (called the "roster"). But the roster is simply a list of the entities that are subscribed to a user's presence. Occam's Razor would indicate that it is foolish to implement two concepts (presence subscription and roster) when one will solve the problem at hand. In XMPP Eventing via Pubsub, there is no need for a specialized "roster" since the same information is represented in the list of entities who are subscribed to the user's "presence" node in pubsub/PEP.</p>
  128. <p>Using XMPP Eventing via Pubsub also cleans up the syntax for presence subscription management, which currently uses four specialized values of the &PRESENCE; element's 'type' attribute: "subscribe", "subscribed", "unsubscribe", and "unsubscribed".</p>
  129. <p>Thus for example a presence subscription request is currently made by sending the following presence stanza:</p>
  130. <example caption='Presence Subscription Request'><![CDATA[
  131. <presence from='bard@shakespeare.lit' to='juliet@capulet.lit' type='subscribe'/>
  132. ]]></example>
  133. <p>And that request is then delivered to the intended recipient:</p>
  134. <example caption='Presence Subscription Request'><![CDATA[
  135. <presence from='bard@shakespeare.lit' to='juliet@capulet.lit' type='subscribe'/>
  136. ]]></example>
  137. <p>In order to approve the subscription request, the user sends a presence stanza of type "subscribed":</p>
  138. <example caption='Presence Subscription Approval'><![CDATA[
  139. <presence from='juliet@capulet.lit' to='bard@shakespeare.lit' type='subscribed'/>
  140. ]]></example>
  141. <p>At this point the user's server also creates an entry on the user's roster for the relevant contact and pushes that entry to the user:</p>
  142. <example caption='Roster Push'><![CDATA[
  143. <iq to=''
  144. type='set'
  145. id='a78b4q6ha463'>
  146. <query xmlns='jabber:iq:roster'>
  147. <item jid='bard@shakespeare.lit'
  148. subscription='from'/>
  149. </query>
  150. </iq>
  151. ]]></example>
  152. <p>Observe how much more elegant it is to use XMPP Eventing via Pubsub:</p>
  153. <example caption='Pubsub Subscription Request'><![CDATA[
  154. <iq type='set'
  155. from='bard@shakespeare.lit/globe'
  156. to='juliet@capulet.lit'
  157. id='sub1'>
  158. <pubsub xmlns=''>
  159. <subscribe
  160. node='presence'
  161. jid='bard@shakespeare.lit'/>
  162. </pubsub>
  163. </iq>
  164. ]]></example>
  165. <p>The pubsub service then sends an authorization request to the user:</p>
  166. <example caption='Service sends authorization request to node owner'><![CDATA[
  167. <message to='juliet@capulet.lit' from='capulet.lit' id='approve1'>
  168. <x xmlns='jabber:x:data' type='form'>
  169. <title>PubSub subscriber request</title>
  170. <instructions>
  171. To approve this entity&apos;s subscription request,
  172. click the OK button. To deny the request, click the
  173. cancel button.
  174. </instructions>
  175. <field var='FORM_TYPE' type='hidden'>
  176. <value></value>
  177. </field>
  178. <field var='pubsub#node' type='text-single' label='Node ID'>
  179. <value>presence</value>
  180. </field>
  181. <field var='pusub#subscriber_jid' type='jid-single' label='Subscriber Address'>
  182. <value>bard@shakespeare.lit</value>
  183. </field>
  184. <field var='pubsub#allow' type='boolean'
  185. label='Allow this JID to subscribe to this pubsub node?'>
  186. <value>false</value>
  187. </field>
  188. </x>
  189. </message>
  190. ]]></example>
  191. <p>In order to approve the request, the owner shall submit the form and set the "pubsub#allow" field to a value of "1" or "true"; for tracking purposes the message MUST reflect the 'id' attribute originally provided.</p>
  192. <example caption='User approves subscription request'><![CDATA[
  193. <message from='juliet@capulet.lit/balcony' to='montague.lit' id='approve1'>
  194. <x xmlns='jabber:x:data' type='submit'>
  195. <field var='FORM_TYPE' type='hidden'>
  196. <value></value>
  197. </field>
  198. <field var='pubsub#node'>
  199. <value>presence</value>
  200. </field>
  201. <field var='pubsub#subscriber_jid'>
  202. <value>bard@shakespeare.lit</value>
  203. </field>
  204. <field var='pubsub#allow'>
  205. <value>true</value>
  206. </field>
  207. </x>
  208. </message>
  209. ]]></example>
  210. <p>Simple. Elegant. And no need for a roster! The pubsub approach is bit more verbose, but then again clients and servers should implement and deploy stream compression if they are really worred about bandwidth usage.</p>
  211. </section1>
  212. <section1 topic='Multi-User Chat' anchor='muc'>
  213. <p>The existing groupchat protocol for XMPP overloads the &PRESENCE; stanza for temporary "subscriptions" to a virtual room and uses the &MESSAGE; stanza (with a special type of "groupchat") to communicate information to multiple room occupants. Sound familiar? It's just another form of pubsub!</p>
  214. <p>In groupchat, a user joins a room by sending presence to "room@service/nick":</p>
  215. <example caption='Groupchat Join'><![CDATA[
  216. <presence from='juliet@capulet.lit/balcony' to='characters@chat.shakespeare.lit/JC'/>
  217. ]]></example>
  218. <p>But on the pubsub model that is merely a temporary subscription, which can be handled quite elegantly as so:</p>
  219. <example caption='Groupchat Join via Pubsub'><![CDATA[
  220. <iq type='set'
  221. from='juliet@capulet.lit/balcony'
  222. to='chat.shakespeare.lit'
  223. id='sub2'>
  224. <pubsub xmlns=''>
  225. <subscribe
  226. node='characters'
  227. jid='juliet@capulet.lit/balcony'/>
  228. <options node='characters' jid='juliet@capulet.lit/balcony'>
  229. <x xmlns='jabber:x:data' type='submit'>
  230. <field var='FORM_TYPE' type='hidden'>
  231. <value></value>
  232. </field>
  233. <field var='roomnick'><value>JC</value></field>
  234. </x>
  235. </options>
  236. </pubsub>
  237. </iq>
  238. ]]></example>
  239. <p>In groupchat, room occupants can send messages to all other occupants via the &MESSAGE; stanza:</p>
  240. <example caption='Groupchat Message'><![CDATA[
  241. <message from='juliet@capulet.lit/balcony' to='characters@chat.shakespeare.lit' type='groupchat'>
  242. <body>hi</body>
  243. </message>
  244. ]]></example>
  245. <p>The groupchat service then "reflects" that message to all the occupants:</p>
  246. <example caption='Groupchat Message Delivery'><![CDATA[
  247. <message from='characters@chat.shakespeare.lit/JC' to='bard@shakespeare.lit/globe' type='groupchat'>
  248. <body>hi</body>
  249. </message>
  250. <message from='characters@chat.shakespeare.lit/JC' to='romeo@montague.lit/mobile' type='groupchat'>
  251. <body>hi</body>
  252. </message>
  253. <message from='characters@chat.shakespeare.lit/JC' to='benvolio@montague.lit/pda' type='groupchat'>
  254. <body>hi</body>
  255. </message>
  256. ]]></example>
  257. <p>But on the pubsub model that is merely a publish resulting in multiple notifications, which can be handled quite elegantly as so:</p>
  258. <example caption='Groupchat Publish'><![CDATA[
  259. <iq from='juliet@capulet.lit/balcony' to='chat.shakespeare.lit' type='set' id='gc1'>
  260. <pubsub xmlns=''>
  261. <publish node='characters'>
  262. <item>
  263. <message xmlns='jabber:client'>
  264. <body>hi</body>
  265. </message>
  266. </item>
  267. </publish>
  268. </pubsub>
  269. </iq>
  270. <iq from='chat.shakespeare.lit' to='juliet@capulet.lit/balcony' type='result' id='gc1'/>
  271. ]]></example>
  272. <p>The service then sends notifications to all the node subscribers:</p>
  273. <example caption='Groupchat Notifications'><![CDATA[
  274. <message from='chat.shakespeare.lit'
  275. to='bard@shakespeare.lit/globe'
  276. id='mucfoo'>
  277. <event xmlns=''>
  278. <items node='characters'>
  279. <item>
  280. <message xmlns='jabber:client'>
  281. <body>hi</body>
  282. </message>
  283. </item>
  284. </items>
  285. </event>
  286. <addresses xmlns=''>
  287. <address type='replyto' jid='juliet@capulet.lit/balcony'/>
  288. </addresses>
  289. </message>
  290. <message from='chat.shakespeare.lit'
  291. to='romeo@montague.lit/mobile'
  292. id='mucfoo'>
  293. <event xmlns=''>
  294. <items node='characters'>
  295. <item>
  296. <message xmlns='jabber:client'>
  297. <body>hi</body>
  298. </message>
  299. </item>
  300. </items>
  301. </event>
  302. <addresses xmlns=''>
  303. <address type='replyto' jid='juliet@capulet.lit/balcony'/>
  304. </addresses>
  305. </message>
  306. <message from='chat.shakespeare.lit'
  307. to='benvolio@montague.lit/pda'
  308. id='mucfoo'>
  309. <event xmlns=''>
  310. <items node='characters'>
  311. <item>
  312. <message xmlns='jabber:client'>
  313. <body>hi</body>
  314. </message>
  315. </item>
  316. </items>
  317. </event>
  318. <addresses xmlns=''>
  319. <address type='replyto' jid='juliet@capulet.lit/balcony'/>
  320. </addresses>
  321. </message>
  322. ]]></example>
  323. <p>Here again the pubsub approach is slightly more verbose, but that's what stream compression is for.</p>
  324. </section1>
  325. <section1 topic='One-to-One Messaging' anchor='messaging'>
  326. <p>It's really rather silly that XMPP includes two different models for messaging, one for groupchat and the other for one-to-one messages. Pubsub solves that problem by using one model for everything. In order to exchange messages, one of the parties simply creates a pubsub node with a whitelist model and adds the other person as a publisher (it may also be necessary to add the other party to the whitelist):</p>
  327. <example caption='Creating a One-to-One Messaging Node'><![CDATA[
  328. <iq type='set'
  329. from='juliet@capulet.lit/balcony'
  330. to='pubsub.shakespeare.lit'
  331. id='create1'>
  332. <pubsub xmlns=''>
  333. <create node='me_and_romeo'/>
  334. <configure>
  335. <x xmlns='jabber:x:data' type='submit'>
  336. <field var='FORM_TYPE' type='hidden'>
  337. <value></value>
  338. </field>
  339. <field var='pubsub#access_model'><value>whitelist</value></field>
  340. <field var='pubsub#publisher'><value>romeo@montague.lit</value></field>
  341. </x>
  342. </configure>
  343. </pubsub>
  344. </iq>
  345. <iq type='result' from='pubsub.shakespeare.lit' to='juliet@capulet.lit/balcony' id='create1'/>
  346. <iq type='set'
  347. from='juliet@capulet.lit/balcony'
  348. id='manage1'>
  349. <pubsub xmlns=''>
  350. <subscriptions node='me_and_romeo'/>
  351. <subscription jid='romeo@capulet.lit' subscription='subscribed'/>
  352. </subscriptions>
  353. </pubsub>
  354. </iq>
  355. <iq type='result'
  356. to='juliet@capulet.lit/balcony'
  357. id='manage1'/>
  358. ]]></example>
  359. <p>Now Juliet can send a message to the node and it will be delivered to both parties (it's always nice to receive a bcc to one's sending address, the client can simply ignore it, or treat it as an ack):</p>
  360. <example caption='Message Publish'><![CDATA[
  361. <iq from='juliet@capulet.lit/balcony' to='pubsub.shakespeare.lit' type='set' id='msg1'>
  362. <pubsub xmlns=''>
  363. <publish node='me_and_romeo'>
  364. <item>
  365. <message xmlns='jabber:client'>
  366. <body>wherefore art thou?</body>
  367. </message>
  368. </item>
  369. </publish>
  370. </pubsub>
  371. </iq>
  372. <iq from='pubsub.shakespeare.lit' to='juliet@capulet.lit/balcony' type='result' id='msg1'/>
  373. ]]></example>
  374. <p>The service then sends notifications to both parties:</p>
  375. <example caption='Groupchat Notifications'><![CDATA[
  376. <message from='pubsub.shakespeare.lit'
  377. to='romeo@montague.lit/mobile'
  378. id='msgfoo'>
  379. <event xmlns=''>
  380. <items node='me_and_romeo'>
  381. <item>
  382. <message xmlns='jabber:client'>
  383. <body>wherefore art thou?</body>
  384. </message>
  385. </item>
  386. </items>
  387. </event>
  388. <addresses xmlns=''>
  389. <address type='replyto' jid='juliet@capulet.lit/balcony'/>
  390. </addresses>
  391. </message>
  392. <message from='pubsub.shakespeare.lit'
  393. to='juliet@capulet.lit/balcony'
  394. id='msgfoo'>
  395. <event xmlns=''>
  396. <items node='me_and_romeo'>
  397. <item>
  398. <message xmlns='jabber:client'>
  399. <body>wherefore art thou?</body>
  400. </message>
  401. </item>
  402. </items>
  403. </event>
  404. <addresses xmlns=''>
  405. <address type='replyto' jid='juliet@capulet.lit/balcony'/>
  406. </addresses>
  407. </message>
  408. ]]></example>
  409. <p>Beautiful, no?</p>
  410. </section1>
  411. <section1 topic='Conclusion' anchor='conclusion'>
  412. <p>Although this document shows how to do presence notifications, presence subscriptions, rosters, groupchat, and one-to-one messaging via pubsub, XMPP Eventing via Pubsub (XEP) is not limited to these functionality areas, which are provided only as examples. Indeed, XMPP Eventing via Pubsub (XEP) provides a generic mechanism for XMPP eventing that obviates the need for any future XMPP Extension Protocol (XEP) specifications other than payload formats for communication over the XMPP Eventing via Pubsub (XEP) transport. Truly, pubsub is the "one ring to bind them all" and the XEP XEP is the mother of all future XEPs. We have a clear path forward to a powerful, robust, payload-agnostic technology for the full range of eventing needs. Let us grasp the opportunity to rebuild XMPP the way it should have been built from the beginning: on top of a solid foundation of publish-subscribe. <note>But did we mention that developers really need to implement stream compression?</note></p>
  413. </section1>
  414. <section1 topic='Security Considerations' anchor='security'>
  415. <p>In XMPP Eventing via Pubsub (XEP), access control is handled through a single permissions model, that of subscriptions to pubsub nodes. XEP nodes MUST have a default access model of "authorize" to prevent open data retrieval from potentially private data sources; this will result in a great deal of authorization requests and thus annoy typical end users to no end, but users will at least have the illusion of security, which is all they really want anyway.</p>
  416. <p>End-to-end encryption is made more difficult in XMPP Eventing via Pubsub (XEP) since all information passes through the pubsub service, which is typically associated with or hosted by the user's server. The solution is to run your own XMPP server in a high-security fashion. In particular, universal deployment of personal XMPP servers, domain certificates (X.509 / PKI) for channel encryption (TLS) and server-to-server trust (SASL), IPv6, DNSSEC, and IPsec will solve all security problems.</p>
  417. <p>If that is not enough, XMPP can utilize onion routing schemes such as Tor for added security. Typically this results in high latency. But the word "instant" in "instant messaging" has always made XMPP seem quite frivolous (especially back when we called it "Jabber", what a silly word that is!), whereas "secure messaging" sounds like a serious technology. Who cares if delivery takes forever? (Oh and while we're at it, we should add per-hop acknowledgements for every stanza and perhaps full transactional abilities; however, those initiatives are beyond the scope of this document.)</p>
  418. </section1>
  419. <section1 topic='IANA Considerations' anchor='iana'>
  420. <p>This document requires no interaction with &IANA;.</p>
  421. </section1>
  422. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  423. <p>This document requires no interaction with the &REGISTRAR;.</p>
  424. </section1>
  425. <section1 topic='XML Schema' anchor='schema'>
  426. <p>Because XMPP Eventing via Pubsub simply reuses the protocol specified in <cite>XEP-0060</cite>, a separate schema is not needed.</p>
  427. </section1>
  428. <section1 topic='Acknowledgements' anchor='ack'>
  429. <p>Thanks to Maciek Niedzielski for inspiration.</p>
  430. </section1>
  431. </xep>