XEP-0304: Whitespace Keepalive Negotiation

Abstract:This specification defines a method for negotiating how to send keepalives in XMPP.
Author:Ming Ji
Copyright:© 1999 - 2014 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status:Deferred
Type:Standards Track
Version:0.1
Last Updated:2011-08-18

WARNING: Consideration of this document has been Deferred by the XMPP Standards Foundation. Implementation of the protocol described herein is not recommended.


Table of Contents


1. Introduction
2. Protocol
3. Use Cases
    3.1. Stream Feature
    3.2. Negotiate Keepalive
4. Implementation Notes
5. Security Considerations
6. IANA Considerations
7. XMPP Registrar Considerations
    7.1. Protocol Namespaces
    7.2. Stream Features
8. XML Schema
9. Acknowledgements

Appendices
    A: Document Information
    B: Author Information
    C: Legal Notices
    D: Relation to XMPP
    E: Discussion Venue
    F: Requirements Conformance
    G: Notes
    H: Revision History


1. Introduction

RFC 6120 [1] specifies that XMPP servers and clients can send whitespace characters between first-level elements of an XML stream as a way to maintain the state of the stream. These "whitespace keepalives" are widely used on the XMPP network. However, currently it is not possible to negotiate the frequency of sending keepalives, or even whether to send keepalives at all (the server simply sends them according to its own schedule). Because certain kinds of devices might not want to use keepalives, or might wish to receive keepalives more frequently or less frequently than the server's default, this specification defines a method for negotiating how to send whitespace keepalives between an XMPP server and an XMPP client (this method could also be used between two servers, although that usage is expected to be rare).

2. Protocol

The protocol defined in this document enables a client negotiate the time interval between whitespace keepalives, within a range determined by the server. Normally, the client starts the negotiation since not all kinds of the client support the feature.

The protocol defines a keepalive element and the normal negotaition process is quite simple, demonstrated as following:

  1. Server announces keepalive feature with a range of time intervals.
  2. Client starts the keepalive negotiation by specifying a time interval.
  3. Server checks the value and relpies with success or failure.

Then server and client send whitespace keepalive to each other at the agreed time interval.

3. Use Cases

3.1 Stream Feature

During the stream negotiation process, the server can advertise this feature. The feature is negotiated after the resource binding. (See Recommended Order of Stream Feature Negotiation (XEP-0170) [2] regarding the recommended order of stream feature negotiation.)

Example 1. Server lists feature in the stream negotiation stage

C: <stream:stream 
           to='example.com' 
           version='1.0' 
           xmlns='jabber:client' 
           xmlns:stream='http://etherx.jabber.org/streams'>
 
C: <stream:stream 
           from='example.com' 
           id='KskA2O2BEn5mL7mABTq9X3DTPHO44vAMaIg1nG9O1vo'
           version='1.0' 
           xmlns='jabber:client' 
           xmlns:stream='http://etherx.jabber.org/streams'>
S:  <stream:features>
        <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
        <keepalive xmlns='urn:xmpp:keepalive:0'>
          <interval min='60' max='300'/> 
        </keepalive>
    </stream:features>
    

3.2 Negotiate Keepalive

Client negotiates the keepalive feature by providing an interval value based on server limits and its own condition. The interval SHOULD be a positive interger, and zero is invalid.

Example 2. Client sends its negotiating keepalive time interval

<iq from='client@example.com/foo' id='p03ns61g' to='example.com' type='set'>
  <keepalive xmlns='urn:xmpp:keepalive:0'>
    <interval>60</interval>
  </keepalive>
</iq>
    

The server checks the keepalive interval value and returns a success:

Example 3. Server returns success of keepalive negotiation

<iq from='example.com' id='p03ns61g' to='client@example.com/foo' type='result'/>
    

If a problem occurs, the server returns an error (in this example, the client sent a value outside the range of the server's preferences):

Example 4. Server returns failure of keepalive negotiation

<iq from='example.com' id='p03ns61g' to='client@example.com/foo' type='error'>
  <error type='cancel'>
    <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  </error>
</iq>
    

Then both the server and the client send whitespace keepalives at the interval of the negotiated value. The server SHOULD check to see if has received keepalives and MAY drop the connection if it has not received a keepalive for a period of time significantly longer than the negotiated value (the client MAY also implement this behavior).

4. Implementation Notes

Several things need to be noted:

  1. Both parties SHOULD keep a record of the keepalive status and honor the negotiated value when allowing stream resumption and session recreation. See Stream Management (XEP-0198) [3]
  2. The length of the keepalive interval depends on the service type and network environment. Implementations are encouraged to use appropriate values based on implementation and deployment experience.

5. Security Considerations

During negotiation, the server MUST check the keepalive interval value and reject any invalid values.

6. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [4].

7. XMPP Registrar Considerations

7.1 Protocol Namespaces

The XMPP Registrar [5] is requested to issue an initial namespace 'urn:xmpp:keepalive:0'

7.2 Stream Features

The XMPP Registrar [6] is requested to issue an initial stream feature namespace 'urn:xmpp:keepalive:0'.

8. XML Schema

<?xml version='1.0' encoding='utf-8'?>

<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'
            targetNamespace='urn:xmpp:keepalive:0'
            xmlns='urn:xmpp:keepalive:0'
            elementFormDefault='unqualified'>
  
  <xsd:element name='keepalive'>
    <xsd:complexType>
      <xsd:attribute name='min' type='positiveShort' use='optional'/>
      <xsd:attribute name='max' type='positiveShort' use='optional'/>
      <xsd:assert test='@min le @max'/>
      <xsd:element name='interval' type='positiveShort' minOccurs='0' maxOccurs='1'/>
    </xsd:complexType>
  </xsd:element>

  <xsd:simpleType name='positiveShort'>
    <xsd:restriction base='xsd:unsignedShort'>
      <xsd:minExclusive value='0'/>
    </xsd:restriction>
  </xsd:simpleType>

</xsd:schema>

  

9. Acknowledgements

Thanks to Matt Miller and Peter Saint-Andre for their feedback.


Appendices


Appendix A: Document Information

Series: XEP
Number: 0304
Publisher: XMPP Standards Foundation
Status: Deferred
Type: Standards Track
Version: 0.1
Last Updated: 2011-08-18
Approving Body: XMPP Council
Dependencies: XMPP Core
Supersedes: None
Superseded By: None
Short Name: NOT_YET_ASSIGNED
Source Control: HTML
This document in other formats: XML  PDF


Appendix B: Author Information

Ming Ji

Email: mingj@cisco.com
JabberID: mingj@cisco.com


Appendix C: Legal Notices

Copyright

This XMPP Extension Protocol is copyright © 1999 - 2014 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <http://xmpp.org/about-xmpp/xsf/xsf-ipr-policy/> or obtained by writing to XMPP Standards Foundation, 1899 Wynkoop Street, Suite 600, Denver, CO 80202 USA).

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards 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.


Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.


Appendix F: Requirements Conformance

The following requirements 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".


Appendix G: Notes

1. RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core <http://tools.ietf.org/html/rfc6120>.

2. XEP-0170: Recommended Order of Stream Feature Negotiation <http://xmpp.org/extensions/xep-0170.html>.

3. XEP-0198: Stream Management <http://xmpp.org/extensions/xep-0198.html>.

4. 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/>.

5. 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 XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.

6. 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 XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.


Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

Version 0.1 (2011-08-18)

Initial published version.

(psa)

Version 0.0.1 (2011-07-19)

First draft.

(mj)

END