<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
  <!ENTITY rfc3920bis "<span class='ref'><link url='http://tools.ietf.org/html/draft-ietf-saintandre-rfc3920bis'>rfc3920bis</link></span> <note>RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url='http://tools.ietf.org/html/draft-ietf-saintandre-rfc3920bis'>http://tools.ietf.org/html/draft-ietf-saintandre-rfc3920bis</link>&gt;.</note>" >
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Bidirectional Server-to-Server Connections</title>
  <abstract>This specification defines a protocol for using server-to-server connections in a bidirectional way such that stanzas are sent and received on the same TCP connection.</abstract>
  &LEGALNOTICE;
  <number>xxxx</number>
  <status>ProtoXEP</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0178</spec>
    <spec>XEP-0220</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  <author>
    <firstname>Philipp</firstname>
    <surname>Hancke</surname>
    <jid>fippo@ve.symlynx.com</jid>
  </author>
  <author>
    <firstname>Dave</firstname>
    <surname>Cridland</surname>
    <email>dave.cridland@isode.com</email>
    <jid>dave.cridland@isode.com</jid>
  </author>
  <revision>
    <version>0.0.2</version>
    <date>2010-09-13</date>
    <initials>dwd</initials>
    <remark>
      <p>belated run-over pre-publication</p>
      <p>Added notes on authentication</p>
    </remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2010-04-12</date>
    <initials>ph</initials>
    <remark><p>initial version</p></remark>
  </revision>
</header>
<section1 topic='Introduction'>
  <p>&rfc3920; restricts server-to-server communication in such a way that a server has to use on TCP connection for XML stanzas sent from the server to the peer and another TCP connection (initiated by the peer) for stanzas from the peer to the server, for a total of two TCP connections. &rfc3920bis; allows two servers to send stanzas in a bidirectional way, but does not define methods for explicitly signalling the usage thereof. This is accomplished in this specification.</p>
</section1>
<!--
http://www.ietf.org/mail-archive/web/xmpp/current/msg00658.html
http://www.ietf.org/mail-archive/web/xmpp/current/msg00664.html
-->
<section1 topic='Protocol' anchor='protocol'>
  <section2 topic='Stream Feature' anchor='feature'>
    <p>If a server supports bidirectional server-to-server streams, it should inform the connecting entity when returning stream features during the stream negotiation process (both before and after TLS negotiation). This is done by including a &lt;bidi/&gt; element qualified by the 'urn:xmpp:features:bidi' namespace.</p>
    <example caption="Stream features"><![CDATA[
<stream:features>
  <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
  <bidi xmlns='urn:xmpp:features:bidi'/>
</stream:features>
]]></example>
    <p>If the initiating entity chooses to use TLS, STARTTLS negotiation MUST be completed before enabling bidirectionality.</p>
  </section2>
  <section2 topic='Negotiation' anchor='nego'>
    <p>To enable bidirectional communication, the connecting server sends a &lt;bidi/&gt; element qualified by the 'urn:xmpp:bidi' namespace. This SHOULD be done before either SASL negotiation or &xep0220;.</p>
    <example caption="Connecting Server Requests Bidirectionality"><![CDATA[
C: <bidi xmlns='urn:xmpp:bidi'/>
]]></example>
    <p>Note: Since there is no reply to the request, it is possible to pipeline it.</p>
    <p>After enabling bidirectionality, the connecting server continues to authenticate via SASL or requests to send stanzas for a domain pair with Server Dialback. The receiving server MUST NOT send stanzas to the peer before it has authenticated via SASL, or the peer's identity has been verified via Server Dialback. Note that the receiving server MUST NOT attempt to verify a dialback key on the same connection where the corresponding request was issued.</p>
    <p>Also note that the receiving server MUST only send stanzas for which it has been authenticated - in the case of TLS/SASL based authentication, this is the value of the stream's 'to' attribute, whereas in the case of &xep0220; this is the value of the 'to' attribute on any &lt;db:result> element.</p>
    <p>Finally, once bidirectionality is enabled, the receiving server MAY initiate &xep0220; authentications for other domains it hosts to any domain authenticated to be hosted by the connecting server.</p>
  </section2>
</section1>
<section1 topic='Examples' anchor='examples'>
  <p>This section shows two complete examples of bidirectional streams, the first example uses SASL EXTERNAL, the second uses Server Dialback. </p>
  <example caption='Bidirectional Streams with SASL Authentication'><![CDATA[
C: <stream:stream xmlns:stream='http://etherx.jabber.org/streams'
	xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	to='montague.lit' from='capulet.lit'
	xml:lang='en' version='1.0'>
S: <stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en'
	id='65b30434afd7646699d077f7affcb2c120c48e18'
	from='montague.lit' to='capulet.lit' version='1.0'>
S: <stream:features>
     <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
     <bidi xmlns='urn:xmpp:bidi'/>
   </stream:features>
C: <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
S: <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
C: <stream:stream xmlns:stream='http://etherx.jabber.org/streams'
	xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	to='montague.lit' from='capulet.lit'
	xml:lang='en' version='1.0'>
S: <stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en'
	id='b5cd769b1dc292c6f6557fe76cabc4d112333f9a'
	from='montague.lit' to='capulet.lit' version='1.0'>
S: <stream:features>
     <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
       <mechanism>EXTERNAL<mechanism>
     </mechanisms>
     <bidi xmlns='urn:xmpp:bidi'/>
   </stream:features>
C: <bidi xmlns='urn:xmpp:bidi'/>
   <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='EXTERNAL'>
     Y2FwdWxldC5saXQ=</auth>
S: <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
C: <stream:stream xmlns:stream='http://etherx.jabber.org/streams'
	xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	to='montague.lit' from='capulet.lit'
	xml:lang='en' version='1.0'>
S: <stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en'
	id='b5cd769b1dc292c6f6557fe76cabc4d112333f9a'
	from='montague.lit' to='capulet.lit' version='1.0'>
S: <stream:features/>
   <!-- At this point, S is allowed to send C stanzas from capulet.lit
        since that is the value of 'to' in the stream open sent by C above.
     -->
C: <iq from='juliet@capulet.lit/balcony' to='montague.lit' type='get'
     id='8dfc70af'><query xmlns='urn:xmpp:ping'/></iq>
S: <iq from='montague.lit' to='juliet@capulet.lit/balcony' type='result'
     id='8dfc70af'><query xmlns='urn:xmpp:ping'/></iq>
]]></example>
  <example caption='Bidirectional Streams with Server Dialback'><![CDATA[
C: <stream:stream xmlns:stream='http://etherx.jabber.org/streams'
	xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	to='montague.lit' from='capulet.lit'
	xml:lang='en' version='1.0'>
S: <stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en'
	id='65b30434afd7646699d077f7affcb2c120c48e18'
	from='montague.lit' to='capulet.lit' version='1.0'>
S: <stream:features>
     <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
     <bidi xmlns='urn:xmpp:bidi'/>
   </stream:features>
C: <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
S: <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
C: <stream:stream xmlns:stream='http://etherx.jabber.org/streams'
	xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	to='montague.lit' from='capulet.lit'
	xml:lang='en' version='1.0'>
S: <stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback'
	xmlns:stream='http://etherx.jabber.org/streams' xml:lang='en'
	id='b5cd769b1dc292c6f6557fe76cabc4d112333f9a'
	from='montague.lit' to='capulet.lit' version='1.0'>
S: <stream:features>
     <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
     <bidi xmlns='urn:xmpp:bidi'/>
   </stream:features>
    <example caption="Stream Setup before TLS"><![CDATA[
C: <bidi xmlns='urn:xmpp:bidi'/>
   <db:result from='capulet.lit' to='montague.lit'>
	e3f5cf21f12749ef2cf59269bc0118f35bc46b26</db:result>
   <!-- At this point S may send from capulet.lit.
     -->
S: <db:result from='montague.lit' to='capulet.lit' type='valid'/>
C: <iq from='juliet@capulet.lit/balcony' to='montague.lit' type='get'
     id='8dfc70af'><query xmlns='urn:xmpp:ping'/></iq>
S: <iq from='montague.lit' to='juliet@capulet.lit/balcony' type='result'
     id='8dfc70af'><query xmlns='urn:xmpp:ping'/></iq>
S: <db:result from='conference.montague.lit' to='capulet.lit'>
        1bac3ef56fed987cfe098c9785c654a5476ed765</db:result>
   <!-- The above is also legal - S attempts to authenticate as
        a different domain as well, presumably a MUC domain
     -->
C: <db:result from='capulet.lit' to='conference.montague.lit' type='valid'/>
   <!-- Now S can send as conference.m.l as well as C sending to that domain.
     -->
]]></example>
</section1>
<section1 topic='Security Considerations' anchor='security'>
  <p>This specification introduces no security considerations above and beyond those discussed in <cite>RFC 3920</cite>.</p>
  <!-- one might explain why not... http://mail.jabber.org/pipermail/xmppwg/2004-February/002026.html -->
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <ul>
      <li>'urn:xmpp:bidi'</li>
    </ul>
  </section2>
  <section2 topic='Stream Features' anchor='registrar-stream'>
    <ul>
      <li>'urn:xmpp:features:bidi'</li>
    </ul>
  </section2>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>
</xep>
