%ents; ]>
Stanza Session Negotiation This specification defines a method for formally negotiating the exchange of XML stanzas between two XMPP entities. The method uses feature negotiation forms sent via XMPP message stanzas to enable session initiation between entities that do not share presence information or have knowledge of full JabberIDs and therefore is also suitable for use across gateways to SIP-based systems. A wide range of session parameters can be negotiated, including the use of end-to-end encryption, chat state notifications, XHTML-IM formatting, and message archiving. &LEGALNOTICE; 0155 Draft Standards Track Standards Council XMPP Core XMPP IM XEP-0020 XEP-0068 ssn &ianpaterson; &stpeter; 1.2 2016-01-20 XEP Editor (mam)

Update missing 'xmppsipim' reference to RFC 7572.

1.2 2008-01-14 psa

Specified that IM message bodies must not be included; added boolean multisession field to explicitly determine whether multiple concurrent sessions are allowed between the full JIDs of the parties.

1.1 2007-03-15 ip/psa

With XMPP Council approval, changed name from Chat Session Negotiation to Stanza Session Negotiation; also changed URN to urn:xmpp:ssn.

1.0 2007-01-17 psa

Per a vote of the XMPP Council, advanced specification to Draft; XMPP Registrar assigned urn:xmpp:chatneg as associated namespace.

0.14 2006-12-21 psa/ip

Specified state chart; added optional presence sharing; renamed otr field to logging; harmonized treatment of renegotiation; per XEP-0053, specified use of provisional namespace until spec advances to Draft.

0.13 2006-11-27 ip

Added disclosure field; changed namespace

0.12 2006-11-10 ip

Removed accept field from renegotiation forms

0.11 2006-11-03 ip

Removed reason field; added new implementation notes; many clarifications including the handling of required fields

0.10 2006-10-31 ip

Defined handling of offline requests; specified localization of the title element and all labels; changed syntax of list of unacceptable fields; removed reason field from some examples; added confirmation message to initial negotiation; clarified the initial participating resources; removed id attributes.

0.9 2006-10-08 ip

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.

0.8 2006-10-02 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.

0.7 2006-07-14 psa

Added secure field from XEP-0116.

0.6 2006-07-13 psa

Specified that a client must re-initiate if it receives presence unavailable; changed document type to Standards Track.

0.5 2006-01-24 psa

Added renegotiate use case.

0.4 2006-01-03 psa

Added terminate use case; further specified mapping to SIP.

0.3 2005-12-30 psa

Further specified use of id attribute and thread element.

0.2 2005-07-15 psa

Further described contexts in which stanza 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.

0.1 2005-07-14 psa

Initial version.

0.0.1 2005-07-12 psa

First draft.

The traditional model for one-to-one chat "sessions" in Jabber/XMPP is for a user to simply send a message to a contact with a thread ID but without any formal negotiation of session parameters (see &xep0201;). This informal approach to initiation of a session is perfectly acceptable in many contexts, environments, and cultures. However, it may be desirable to formally request a chat session (or any other type of XMPP stanza session) and negotiate its parameters before beginning the session in some circumstances, such as:

This proposal defines best practices for such a negotiation, re-using the protocol defined in &xep0020;.

The specification addresses the following use cases:

The following figure attempts to capture the state transitions in visual form.

o | [1] | PENDING o---------------+ | | | [3] | | [2]-----[5]------| | | [4] | | | | | ACTIVE o | | | +------+ | | | | | [6] | | | | | [7] or [8] | | | | +------+ | | | +-----[9]-------+ | o ENDED

[1] A stanza session negotiation is initiated when the user sends a message containing a data form of type "form" with an "accept" field.

[2] A stanza session negotiation is accepted when the contact sends a message containing a data form of type "submit" with an "accept" field whose value is "1" or "true".

[3] A stanza session negotiation is rejected when the contact sends a message containing a data form of type "submit" with an "accept" field whose value is "0" or "false".

[4] A stanza session negotiation is completed when the user sends a message containing a data form of type "result" with an "accept" field whose value is "1" or "true".

[5] A stanza session negotiation is canceled when the user sends a message containing a data form of type "result" with an "accept" field whose value is "0" or "false".

[6] An existing session is re-negotiated when either party sends a message containing a data form of type "form" with a "renegotiate" field whose value is "1" or "true".

[7] A session re-negotiation is accepted when the other party sends a message containing a data form of type "submit" with a "renegotiate" field whose value is "1" or "true".

[8] A session re-negotiation is rejected when the other party sends a message containing a data form of type "submit" with a "renegotiate" field whose value is "0" or "false"; however, the session remains in the active state with the previously-negotiated parameters in force.

[9] A session is terminated when either party sends a message containing a data form of type "submit" with a "terminate" field whose value is "1" or "true".

In order to initiate a negotiated session, the initiating party ("user") sends a &MESSAGE; 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). 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 &rfc3921;). The &MESSAGE; stanza type SHOULD be "normal" (either explicitly or by non-inclusion of the 'type' attribute). The stanza 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 "urn:xmpp:ssn" and MUST contain a boolean field named "accept". &BOOLEANNOTE; The inclusion of "logging", "disclosure" and "security" fields is also RECOMMENDED. Note: The options within any 'list-single' fields SHOULD appear in order of preference.

Note: Sessions may be conducted between entities who are never online at the same time. However, if the user is interested only in an immediate session then the user SHOULD instruct the contact's server not to store the message for later delivery (see &xep0160;) using the &xep0079; protocol.

In the following example of a negotiation request, Romeo requests a chat with Juliet and also queries her regarding whether she is able to disallow all message logging (see &xep0136;) A client MUST NOT set the 'logging' field to 'mustnot' unless it has confirmed that its server will allow it to switch off Automated Archiving (see Message Archiving)., whether she wants to temporarily share presence for this session (see the Sharing Presence section of this document), and whether she wants to support the &xep0071; and &xep0085; extensions during this session. He asks Juliet's client if it is prepared to make a (legally binding) guarantee that it does not intentionally implement any feature (not even a disabled feature) that might disclose the content of the session, any associated (decryption) keys, or his identity to any third-party (see Encrypted Session Negotiation). He also requires that they are both connected securely to their servers, and asks which language she prefers amongst those he can write.

Note: These fields are examples only. For definitions of these fields, refer to the Defined Parameters section of this document.

ffd7076498744578d10edabfe7f4a866 Open chat with Romeo? urn:xmpp:ssn true mustnot never false may may may c2s en ]]>

The user MAY request a session with a specific resource of the contact. However, if the user specifies no resource (or if the specified resource is not available), then the contact's server delivers the request to the contact's most available resource (which in the examples below happens to be "balcony"). If no resource is available (and no Advanced Message Processing rule included in the request specifies otherwise) then the server MAY store the request for later delivery.

If, upon reception of a user's session request, a contact finds that the request had been stored for later delivery, and if the contact is interested only in an immediate session, then it SHOULD initiate a new stanza session negotiation (including a newly-generated ThreadID) instead of responding to the user's request. Note: Sending any response to the user's original request would leak presence information since it would divulge the fact that the contact had been offline rather than just ignoring the user.

In any response to the user's request, the contact's client MUST mirror the &THREAD; value so that the user's client can correctly track the response. The &MESSAGE; stanza MUST NOT contain a &BODY; child element.

If the request is accepted then the contact's client MUST include in its response values for all the fields that the request indicated are required. 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 session and specifies that she prefers to speak Italian with Romeo:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn true mustnot never may may c2s it ]]>

Note: Both entities MUST assume the session is being established with the resource of the contact that sends the reply, even if the user sent its request to a different resource of the contact.

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 Presence Leaks). 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 session.

However, if the contact simply prefers not to start a session then the client SHOULD decline the invitation. The data form MUST contain the FORM_TYPE field and the "accept" field set to "0" or "false". It is RECOMMENDED that the form does not contain any other fields even if the request indicated they are required. The client MAY include a reason via the "reason" field (which is of type "text-single"). The &MESSAGE; stanza MUST NOT contain a &BODY; child element.

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 0 Sorry, can't chat now! How about tonight? ]]>

If the contact's client does not support feature negotiation or does not support the "urn:xmpp:ssn" FORM_TYPE, it SHOULD return a &unavailable; error:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn ... ]]>

If the contact's client does not support one or more of the required features, it SHOULD return a &feature; error, specifying the field(s) not implemented using the 'var' attribute of one or more <field/> child elements of a <feature/> child element of the <error/> scoped by the 'http://jabber.org/protocol/feature-neg' namespace:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn ... ]]>

If the contact's client supports none of the options for one or more required fields, it SHOULD return a ¬acceptable; error, specifying the field(s) with unsupported options using the 'var' attribute of one or more <field/> child elements of a <feature/> child element of the <error/> scoped by the 'http://jabber.org/protocol/feature-neg' namespace:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn ... ]]>

If the contact accepted the session (see Accepting a Session) then the user MUST either complete or cancel the stanza session negotiation. If the contact chose an option other than the default (prefered) value for one or more of the fields, then instead of having the client accept the session automatically the user may prefer to review the values that the contact selected before confirming that the session is open. See Encrypted Session Negotiation for example of other instances where the user might find the values submitted by the contact unacceptable. In any case the user's client SHOULD verify that the selected values are acceptable before completing the stanza session negotiation -- and confirming that the session is open -- by replying with a form with the form 'type' attribute set to 'result'. The form MUST contain the FORM_TYPE field and the "accept" field set to "1" or "true". The user MAY include an explanation or reason via the "reason" field (which is of type "text-single"). The &MESSAGE; stanza MUST NOT contain a &BODY; child element.

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn true I forgot what I wanted to say! ]]>

Alternatively, if the user decides to cancel the stanza session negotiation then the client MUST reply with a data form containing the FORM_TYPE field and the "accept" field set to "0" or "false":

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 0 ]]>

Either party MAY ask to continue the session using another of its resources. The requesting party does this by submitting a form with a "continue" field containing the value of the new resource:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn PDA ]]>

The requesting party SHOULD NOT send stanzas within the session from either resource until the other party has accepted the switch to the new resource.

The other client SHOULD accept the switch automatically since the requesting party might otherwise be unable to continue the session:

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn PDA ]]>

Once the other party has accepted the switch then all stanzas sent within the session MUST be to or from the new resource. Note: Both parties MUST ensure that they comply with all the other stanza session negotiation parameters that were previously agreed for this session.

At any time during an existing session, either party MAY attempt to renegotiate the parameters of the session using the protocol described in Negotiating a New 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 session. Note: The "accept" field MUST NOT be included in a renegotiation form and the &MESSAGE; stanza MUST NOT contain a &BODY; child element. The other fields MAY be different from the set of fields included in the initial stanza session negotiation form.

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 1 mustnot ]]>

The requesting party MAY continue to send stanzas within the session while it is waiting for the other party to either accept the parameters or report an error.

In order to accept the renegotiation, the other party shall send a message containing a data form of type "submit" with the 'renegotiate' field set to a value of "1" or "true".

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 1 may ]]>

Note: Both parties MUST consider the renegotiation to be complete as soon as the parameter acceptance message has been sent (or received).

Note: The requesting party SHOULD NOT send a renegotiation completion or cancelation message (see Completing or Canceling the Negotiation).

Note: Both parties MUST ensure that they continue to comply with all the stanza session negotiation parameters that were not renegotiated but had previously been agreed for this session.

In order to reject the renegotiation, the other party shall send a message containing a data form of type "submit" with the 'renegotiate' field set to a value of "0" or "false".

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 0 may ]]>

If the other party's client does not support one or more of the required features, it SHOULD return a &feature; error. If the other party's client supports none of the options for one or more required fields, it SHOULD return a ¬acceptable; error (see Rejecting a Session). Note: In any of these cases the existing negotiated session parameters are maintained. Either party MAY choose to terminate the session only as specified in the section Terminating a Session.

In order to explicitly terminate a negotiated session, the party that wishes to end the session MUST do so by sending a &MESSAGE; containing a data form of type "submit". The &MESSAGE; stanza MUST contain a &THREAD; element with the same XML character data as the original initiation request. The &MESSAGE; stanza MUST NOT contain a &BODY; child element. The data form containing a boolean field named "terminate" set to a value of "1" or "true".

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 1 ]]>

Both parties MUST then consider the session to be ended.

The other party's client MAY explicitly acknowledge the termination of the session by sending a &MESSAGE; containing a data form of type "result", and the value of the "terminate" field set to "1" or "true" (see Encrypted Session Negotiation for a practical example). The client MUST mirror the &THREAD; value it received.

ffd7076498744578d10edabfe7f4a866 urn:xmpp:ssn 1 ]]>

This section defines the parameters for stanza session negotiation parameters and whether they must, should, or may be included in the initial negotiation form. Additional parameters may be registered as described in the XMPP Registrar Considerations section of this document.

Name Definition Inclusion
accept Whether the receiving party wishes to accept the invitation MUST
continue Another resource with which to continue the session N/A (used to move a session)
disclosure Whether and to what extent the content, keys, and identities can be disclosed to third parties; the options are "never" (disclosure must never occur), "disabled" (only disclosure required by law shall occur), and "enabled" (disclosure may occur) SHOULD
http://jabber.org/protocol/chatstates Whether the parties may exchange Chat State Notifications per XEP-0085; the options are "may" and "mustnot" OPTIONAL
http://jabber.org/protocol/xhtml-im Whether the parties may exchange XHTML formatting per XEP-0071; the options are "may" and "must not" OPTIONAL
language The preferred natural language(s) for information exchange, using language codes defined in accordance with &rfc4646; SHOULD
logging Whether the parties may log messages; the options are "may" and "mustnot" SHOULD
multisession Whether to allow multiple concurrent sessions between the full JIDs of the parties; this is a boolean variable that defaults to false SHOULD
renegotiate Whether the receiving party wishes to renegotiate the session N/A (used to renegotiate a session)
security The minimum security level for secure connections between the parties; the options are "none" (a secure connection is not required), "c2s" (both parties must be securely connected to their servers), and "e2e" (both parties must be securely connected to each other, for example via Encrypted Sessions) SHOULD
terminate Whether the receiving party wishes to terminate the session N/A (used to terminate a session)

A client MAY require a human user to approve each stanza session negotiation request, however it is RECOMMENDED that it accepts or rejects automatically as many requests as possible, based on a set of user-configurable policies (see Presence Leaks).

Stanza session negotiation sometimes requires the involvement of either or both human users, and if human input is required but the user is away then session establishment may be delayed indefinitely. So, in order to minimise the number of user interruptions and delays, clients SHOULD reuse existing sessions whenever possible. For example, a client SHOULD NOT terminate sessions unless the user is going offline, even if its user closes a window associated with the session.

If so negotiated via the 'presence' field, two parties who do not have subscriptions to each other's presence (as specified in XMPP-IM) may share presence by sending directed presence after the session is negotiated.

]]> ]]>

In accordance with the rules specified in XMPP-IM, sharing presence enables one party's server to send unavailable presence to the other party if the sending party goes offline for any reason.

If a party receives an XMPP presence stanza of type "unavailable" from the full JID &LOCALFULL; of the other party (i.e., the resource with which it has had an active session) during a session, the receiving party SHOULD assume that the other client will still be able to continue the session (perhaps it simply became "invisible", or it is persisting the state of the negotiated session until it reconnects and receives "offline" messages).

However, the receiving party MAY assume that the other client will not be able to continue the session. In general, if a party is not subscribing to the other party's presence then it will never assume the other party is is unable to continue a session. In that case it MUST explicitly terminate the session (see Terminating a Session) -- since its assumption could be incorrect. If after terminating the session the receiving party later receives available presence (i.e., a &PRESENCE; stanza with no 'type' attribute) from that same resource or another resource associated with the other party and the receiving party desires to restart the session, then it MUST initiate a new session (including a newly-generated ThreadID) with the other party. It MUST NOT renegotiate parameters for the terminated session. (Note: This is consistent with the handling of chat states as specified in XEP-0085.)

When mapping instant messaging flows to SIP, implementations SHOULD adhere to &rfc7572;.

In addition, the following mappings apply to chat session negotiation:

  • Initiation of a negotiated chat session maps to the semantics of the SIP INVITE method.
  • Renegotiation of a negotiated chat session also maps to the semantics of the SIP INVITE method.
  • Termination of a negotiated chat session maps to the semantics of the SIP BYE method.
  • The XMPP &THREAD; value maps to the semantics of the SIP Call-ID attribute.

If a contact does not share its presence information with a user through a presence subscription (see RFC 3921) or if it blocks outbound presence notifications to the user (see &xep0016;), then it will effectively expose its presence if it accepts the user's stanza session negotiation request or returns an error to the user. Therefore, due care must be exercised in determining whether to accept the request or return an error. 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 subscribed to the contact's presence and the contact is not blocking outbound presence notifications to the user. Note: There should be no need for the contact's client to consult the contact's block list (see &xep0191;), since if the user is on the block list then the contact would not receive the request from the user in the first place.

If a client is configured to show a request <form/> to a human user instead of responding automatically, it SHOULD replace the content of the <title/> element and of all label attributes of the known and registered <field/> and <option/> elements with its own localised versions before showing the form to the user -- even if the form already appears to be in the correct language.

Note: If a client fails to localize the form, a malicious contact might, for example, either switch the labels on the 'security' and 'logging' fields, or use the <title/> to mislead the user regarding the identity of the contact.

This document requires no interaction with &IANA;.

The ®ISTRAR; includes 'urn:xmpp:ssn' in its registry of protocol namespaces (see &NAMESPACES;).

The XMPP Registrar includes 'urn:xmpp:ssn' in its registry of Service Discovery features (see &DISCOFEATURES;).

urn:xmpp:ssn Support for Stanza Session Negotiation and its FORM_TYPE XEP-0155 ]]>

&xep0068; defines a process for standardizing the fields used within Data Forms qualified by a particular namespace. The following fields are registered for use in Stanza Session Negotiation (see &FORMTYPES;):

urn:xmpp:ssn XEP-0155 Forms enabling negotation of a one-to-one session between two entities. ]]>

This proposal re-uses the format defined in XEP-0020 and therefore does not require a dedicated schema.

Thanks to Thomas Charron and Jean-Louis Seguineau for their feedback.