This document specifies a feature negotiation profile for initiating a one-to-one chat session.
WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the Jabber Software Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems should not deploy implementations of this protocol until it advances to a status of Draft.
Status:
Experimental
Type:
Standards Track
Number: 0155
Version: 0.9
Last Updated: 2006-10-05
Publishing Organization: Jabber Software Foundation
Approving Body: XMPP Council
Dependencies: XMPP Core, XMPP IM, XEP-0020, XEP-0068
Supersedes: None
Superseded By: None
Short Name: chatneg
Wiki Page: <http://wiki.jabber.org/index.php/Chat Session Negotiation (XEP-0155)>
Email:
stpeter@jabber.org
JID:
stpeter@jabber.org
Email:
ian.paterson@clientside.co.uk
JID:
ian@zoofy.com
This XMPP Extension Protocol is copyright 1999 - 2006 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.xmpp.org/extensions/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).
The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The following keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
The traditional model for one-to-one chat "sessions" in Jabber/XMPP is for a user to simply send a message to a contact without any formal negotiation of chat session parameters (e.g., see XMPP IM [1]). This informal approach to initiation of a chat session is perfectly acceptable in many contexts, environments, and cultures. However, it may be desirable to formally request the chat and negotiate its parameters before beginning the chat session in some circumstances, such as:
This proposal defines best practices for such a negotiation, re-using the protocol defined in Feature Negotiation [8].
In order to initiate a negotiated chat session, the initiating party ("user") sends a <message/> [9] stanza to the receiving party ("contact") containing a <feature/> child qualified by the 'http://jabber.org/protocol/feature-neg' namespace. The <message/> stanza MUST NOT contain a <body/> child element (as specified in RFC 3921 [10]). The <message/> stanza type SHOULD be "normal" (either explicitly or by non-inclusion of the 'type' attribute). The stanza MAY include an 'id' attribute and MUST contain a <thread/> element for tracking purposes (where the newly-generated ThreadID is unique to the proposed session). The data form MUST contain a hidden FORM_TYPE field whose value is "http://jabber.org/protocol/chatneg" and MUST contain a boolean field named "accept". [11] The inclusion of "otr" and "security" fields is also RECOMMENDED. Note: The options within any 'list-single' fields SHOULD appear in order of preference.
In the following example of a negotiation request, Romeo requests a chat with Juliet and also queries her regarding whether she wants to enable all message logging (see Message Archiving [12]) [13] and support the XHTML-IM [14] and Chat State Notifications [15] extensions during this chat session. He also requires that they are both connected securely to their servers, and asks which language she prefers amoungst those he can write. (Note: These fields are examples only; a full set of chat session negotiation parameters will be registered as described in the XMPP Registrar Considerations section of this document.)
<message type='normal' from='romeo@montague.net/orchard' to='juliet@capulet.com' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='form'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field label='Accept this chat?' type='boolean' var='accept'> <value>true</value> <required/> </field> <field label='Off-The-Record?' type='list-single' var='otr'> <value>false</value> <option label='Allow message logging'> <value>false</value> </option> <option label='Disable all message logging'> <value>true</value> </option> </field> <field label='XHTML Formatting?' type='list-single' var='http://jabber.org/protocol/xhtml-im'> <value>true</value> <option label='Disable'><value>false</value></option> <option label='Enable'><value>true</value></option> </field> <field label='Chat State Notifications?' type='list-single' var='http://jabber.org/protocol/chatstates'> <value>true</value> <option label='Disable'><value>false</value></option> <option label='Enable'><value>true</value></option> </field> <field label='Minimum security level' type='list-single' var='security'> <value>c2s</value> <option label='Both parties must be securely connected to their servers'> <value>c2s</value> </option> </field> <field label='Primary written language of the chat' type='list-single' var='language'> <value>en</value> <option label='English'><value>en</value></option> <option label='Italiano'><value>it</value></option> </field> <field label='Reason' type='text-single' var='reason'> <value>Can we talk?</value> </field> </x> </feature> </message>
The contact's server delivers the request to the contact's most available resource (which in the examples below happens to be "balcony").
In any response to the request, the contact's client MUST mirror any 'id' attribute and <thread/> value so that the user's client can correctly track the response.
If the contact's client does not support one of the default values or if the contact has disabled its support (as for Chat State Notifications and XHTML formatting in the example below), and the client can still accept the request, then it MUST set that field to a value that it can support.
In the example below we assume that Juliet accepts the chat and specifies that she prefers to speak Italian with Romeo:
<message type='normal' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='accept'><value>true</value></field> <field var='otr'><value>false</value></field> <field var='http://jabber.org/protocol/xhtml-im'> <value>false</value> </field> <field var='http://jabber.org/protocol/chatstates'> <value>false</value> </field> <field var='security'><value>c2s</value></field> <field var='language'><value>it</value></field> <field var='reason'> <value>OK, but I'm too tired to practice my English!</value> </field> </x> </feature> </message>
If the contact does not want to reveal presence to the user for whatever reason then the contact's client SHOULD return no response or error (see Security Considerations). Also, if the contact is using a legacy client then it MAY not support returning any response or error. In both these cases the user MAY, proceed to send stanzas to the contact outside the context of a negotiated chat session.
However, if the contact simply prefers not to chat then the client SHOULD decline the invitation:
<message type='normal' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='accept'><value>0</value></field> <field var='reason'> <value>Sorry, can't chat now! How about tonight?</value> </field> </x> </feature> </message>
If the contact's client does not support feature negotiation or does not support the "http://jabber.org/protocol/chatneg" FORM_TYPE, it SHOULD return a <service-unavailable/> error:
<message type='error' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <error code='503' type='cancel'> <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> </error> </message>
If the contact's client does not support one or more of the required features, it SHOULD return a <feature-not-implemented/> error and SHOULD specify the field(s) not implemented in a comma-separated list in the XMPP <text/> element:
<message type='error' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <error code='501' type='cancel'> <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>otr</text> </error> </message>
If the contact's client supports none of the options for one or more fields, it SHOULD return a <not-acceptable/> error and SHOULD specify the field(s) with unsupported options in a comma-separated list in the XMPP <text/> element:
<message type='error' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='init1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <error code='501' type='cancel'> <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>security</text> </error> </message>
At any time during an existing chat session, either party MAY attempt to renegotiate the parameters of the session. The requesting party does this by sending a new <message/> stanza containing a feature negotiation form and a <thread/> element with the same value as that of the existing chat session.
Note: The "accept" field SHOULD NOT be included in a renegotiation form. The set of other fields in the form MAY be different from the set included in the initial session negotitation.
<message type='normal' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='reneg1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='form'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field label='Off-The-Record?' type='list-single' var='otr'> <value>true</value> <option label='Disable all message logging'> <value>true</value> </option> </field> <field label='Reason' type='text-single' var='reason'> <value>Lets keep this private!</value> </field> </x> </feature> </message>
<message type='normal' from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' id='reneg1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='otr'><value>true</value></field> <field var='reason'> <value>Yes, the sys admin might tell our families!</value> </field> </x> </feature> </message>
If the other party's client does not support one or more of the required features, it SHOULD return a <feature-not-implemented/> error instead, while if it supports none of the options for one or more fields, it SHOULD return a <not-acceptable/> error instead (see Initiating a Chat). In either of these cases the existing negotiated chat session parameters are maintained. Either party MAY then terminate the chat session as specified in the section Terminating a Chat.
Either party MAY use chat renegotiation to attempt to continue the session using another of its resources. The requesting party does this by sending a feature renegotiation form with a "continue" field containing the value of the new resource:
<message type='normal' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='reneg2'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='form'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field label='New client name' type='text-single' var='continue'> <value>PDA</value> </field> <field label='Reason' type='text-single' var='reason'> <value>I am leaving the orchard.</value> </field> </x> </feature> </message>
The requesting party SHOULD NOT send stanzas within the session from either resource until the other party has accepted or rejected (with a <feature-not-implemented/> error) the switch to the new resource.
The other party SHOULD accept the switch since the requesting party might otherwise be unable to continue the session:
<message type='normal' from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' id='reneg2'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='continue'><value>PDA</value></field> <field var='reason'><value>OK, hurry to me.</value></field> </x> </feature> </message>
Once the other party has accepted the switch then all stanzas sent within the chat session MUST be to or from the new resource. Note: Both parties MUST ensure that they comply with all the other chat session negotiation parameters that were previously agreed for this session.
In order to explicitly terminate a negotiated chat, the party that wishes to end the chat MUST do so by sending a <message/> containing a data form of type "submit". The <message/> stanza SHOULD possess an 'id' attribute and MUST contain a <thread/> element with the same XML character data as the original initiation request. The data form containing a boolean field named "terminate" set to a value of "1" or "true" and MAY also contain a "reason" field.
<message type='normal' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='term1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='submit'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='terminate'><value>1</value></field> <field var='reason'><value>Gotta go!</value></field> </x> </feature> </message>
Both parties MUST then consider the chat session to be ended.
The other party's client MAY explicitly acknowledge the termination of the chat by sending a <message/> containing a data form of type "result", with no "reason" field and the value of the "terminate" field set to "1" or "true". The client MUST mirror the 'id' attribute and <thread/> value it received.
<message type='normal' from='romeo@montague.net/orchard' to='juliet@capulet.com/balcony' id='term1'> <thread>ffd7076498744578d10edabfe7f4a866</thread> <feature xmlns='http://jabber.org/protocol/feature-neg'> <x xmlns='jabber:x:data' type='result'> <field var='FORM_TYPE' type='hidden'> <value>http://jabber.org/protocol/chatneg</value> </field> <field var='terminate'><value>1</value></field> </x> </feature> </message>
When mapping instant messaging flows to SIP, implementations SHOULD adhere to draft-saintandre-xmpp-simple [16].
In addition, the following mappings apply to chat session negotiation:
A client MAY require a human user to approve each chat session negotiation request or MAY auto-accept and auto-reject requests based on some user-configurable policy.
If a party receives XMPP presence of type "unavailable" from the full JID (<node@domain.tld/resource>) of the other party (i.e., the resource with which it has had an active session) during a chat session, the receiving party MAY assume that the other client will still be unable to continue the session (perhaps it simply became "invisible", or it is persisting the state of the negotiated chat until it reconnects and receives "offline" messages). However, if the receiving party assumes that the other client will not be able to continue the session, then it MUST explicitly terminate the session (see Terminating a Chat) - since its assumption could be incorrect. If the receiving party later receives presence of type "available" from that same resource or another resource associated with the other party and the receiving party desires to restart the chat session, it MUST initiate a new chat session (including a newly-generated ThreadID) with the other party rather than renegotiate parameters for the terminated session. (Note: This is consistent with the handling of chat states as specified in XEP-0085.)
If a contact accepts a user's request or returns an error to the user, the user will effectively discover the contact's presence (at least the presence of one of the contact's resources). Due care must therefore be exercised in determining whether to accept the request or return an error. For examples, the contact's client SHOULD NOT automatically (i.e. without first asking the contact) either accept the user's request or return an error to the user unless the user is subscribing to the contact's presence (and the contact's presence is not currently "invisible" to the user). Furthermore, the contact's client MUST NOT take either action if the user is in the contact's block list.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [17].
The XMPP Registrar [18] shall include 'http://jabber.org/protocol/chatneg' in its registry of Service Discovery features.
<var> <name>http://jabber.org/protocol/chatneg</name> <desc>Support for Chat Session Negotiation and its FORM_TYPE</desc> <doc>XEP-0155</doc> </var>
Field Standardization for Data Forms [19] defines a process for standardizing the fields used within Data Forms qualified by a particular namespace. The following fields shall be registered for use in Chat Session Negotiation:
<form_type> <name>http://jabber.org/protocol/chatneg</name> <doc>XEP-0155</doc> <desc> Forms enabling negotation of a one-to-one chat session between two entities. </desc> <field var='accept' type='boolean' label='Whether to accept the invitation'/> <field var='continue' type='text-single' label='Another resource with which to continue the session'/> <field var='http://jabber.org/protocol/chatstates' type='list-single' label='Whether to enable Chat State Notifications per XEP-0085'> <option label='Disable'> <value>false</value> </option> <option label='Enable'> <value>true</value> </option> </field> <field var='http://jabber.org/protocol/xhtml-im' type='list-single' label='Whether to enable XHTML-IM formatting per XEP-0071'/> <option label='Disable'> <value>false</value> </option> <option label='Enable'> <value>true</value> </option> </field> <field var='language' type='list-single' label='Primary written language of the chat (each value appears in order of preference and conforms to RFC 4646 and the IANA registry)'/> <field var='otr' type='list-single' label='Off-The-Record'> <option label='Allow message logging'> <value>false</value> </option> <option label='Disable absolutely all message logging including automatic archiving - see XEP-0136'> <value>true</value> </option> </field> <field var='reason' type='text-single' label='A reason for chatting (or not)'/> <field var='security' type='list-single' label='Minimum security level'> <option label='Secure connections not required'> <value>none</value> </option> <option label='Both parties must be securely connected to their servers'> <value>c2s</value> </option> <option label='Both parties must be securely connected to each other'> <value>e2e</value> </option> </field> <field var='terminate' type='boolean' label='Whether to terminate the session'/> </form_type>
This proposal re-uses the format defined in XEP-0020 and therefore does not require a separate schema.
Thanks to Thomas Charron and Jean-Louis Seguineau for their feedback.
1. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://www.ietf.org/rfc/rfc3921.txt>.
2. XEP-0116: Encrypted Sessions <http://www.xmpp.org/extensions/xep-0116.html>.
3. XEP-0136: Message Archiving <http://www.xmpp.org/extensions/xep-0136.html>.
4. XEP-0030: Service Discovery <http://www.xmpp.org/extensions/xep-0030.html>.
5. XEP-0115: Entity Capabilities <http://www.xmpp.org/extensions/xep-0115.html>.
6. RFC 3261: Session Initiation Protocol (SIP) <http://www.ietf.org/rfc/rfc3261.txt>.
7. In essence, a chat state negotiation request as specified herein is functionally equivalent to a SIP INVITE request, and acceptance of such a request is functionally equivalent to sending a SIP 200 OK response; see Section 17 of RFC 3261.
8. XEP-0020: Feature Negotiation <http://www.xmpp.org/extensions/xep-0020.html>.
9. The <message/> stanza is used because the user does not necessarily know which of the contact's resources is most available (or indeed if the contact is online).
10. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://www.ietf.org/rfc/rfc3921.txt>.
11. In accordance with Section 3.2.2.1 of XML Schema Part 2: Datatypes, the allowable lexical representations for the xs:boolean datatype are the strings "0" and "false" for the concept 'false' and the strings "1" and "true" for the concept 'true'; implementations MUST support both styles of lexical representation.
12. XEP-0136: Message Archiving <http://www.xmpp.org/extensions/xep-0136.html>.
13. A client MUST NOT set the 'otr' field to 'true' unless it has confirmed that its server will allow it to switch off Automated Archiving (see Message Archiving).
14. XEP-0071: XHTML-IM <http://www.xmpp.org/extensions/xep-0071.html>.
15. XEP-0085: Chat State Notifications <http://www.xmpp.org/extensions/xep-0085.html>.
16. Basic Messaging and Presence Interoperability between the Extensible Messaging and Presence Protocol (XMPP) and Session Initiation Protocol (SIP) for Instant Messaging and Presence Leveraging Extensions (SIMPLE) <http://www.ietf.org/internet-drafts/draft-saintandre-xmpp-simple-05.txt> (work in progress).
17. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
18. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the Jabber Software Foundation. For further information, see <http://www.xmpp.org/registrar/>.
19. XEP-0068: Field Data Standardization for Data Forms <http://www.xmpp.org/extensions/xep-0068.html>.
Added language field; replaced secure field with security field; changed type of otr, XHTML and Chat State fields from boolean to list-single; added not-acceptable error; several clarifications.
(ip)Added continue field and optional terminate acknowledgement; specified renegotiation failure proceedure; added context to Introduction; changed unavailable presence handling; renamed logging field to otr.
(ip)Added secure field from XEP-0116.
(psa)Specified that a client must re-initiate if it receives presence unavailable; changed document type to Standards Track.
(psa)Added renegotiate use case.
(psa)Added terminate use case; further specified mapping to SIP.
(psa)Further specified use of id attribute and thread element.
(psa)Further described contexts in which chat session negotiation could be useful; added more examples; added reference to SIP RFC and explained basic mapping to SIP INVITE method; added XMPP Registrar considerations.
(psa)Initial version.
(psa)First draft.
(psa)END