XEP-0410: MUC Self-Ping (Schrödinger's Chat)

This protocol extension for XEP-0045 Multi User Chat allows clients to check whether they are still joined to a chatroom.
Georg Lukas
© 2018 – 2019 XMPP Standards Foundation. SEE LEGAL NOTICES.


NOTICE: The protocol defined herein is a Stable Standard of the XMPP Standards Foundation. Implementations are encouraged and the protocol is appropriate for deployment in production systems, but some changes to the protocol are possible before it becomes a Final Standard.
Standards Track
1.1.0 (2019-09-25)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

The Multi-User Chat (XEP-0045) [1] protocol was not designed to handle s2s interruptions or message loss well. Rather often, the restart of a server or a component causes a client to believe that it is still joined to a given chatroom, while the chatroom service does not know of this occupant.

Existing approaches for re-synchronization are either inefficient (presence updates and "silent" messages are reflected to all occupants, totalling to O(N²) stanzas per time unit), or mask message / presence losses (the implicit join performed via the deprecated GC1.0 protocol).

This specification aims to provide the most efficient, albeit not the most elegant, way for clients to periodically check whether they are still joined to a chatroom. However, it can not ensure that a client remains joined to a room without any interruptions.

2. Requirements

This specification only makes sense in the context of Multi-User Chat (XEP-0045) [1] chatrooms. It makes use of XMPP Ping (XEP-0199) [2] to perform periodic self-pings.

Server support for this extension is optional, but will significantly improve the reliability with Multi-Session Nicks and mobile clients.

3. Client Self-Presence Check

A typical connection between a client and a Multi-User-Chatroom (MUC) goes through the client-to-server link, possibly a server-to-server link and a typically local server-to-component link. If one of the involved servers or the MUC component is restarted, or one of the links is disturbed for some time, this can lead to the removal of some or all occupants from the affected MUCs, without the clients being informed.

To an occupant, this looks like the MUC is silent (there is no chat activity and no presence changes), making it hard to realize that the connection was interrupted.

To prevent the bad usability effect (message loss, lack of reaction from people in a chatroom), a client needs to actively check whether it is still joined to a MUC.

3.1 Possible Protocol Approaches

There are multiple alternative approaches for a client to test whether it is still joined to a MUC:

  1. Silent message (e.g. Chat State Notifications (XEP-0085) [3]): this message will be reflected to all MUC occupants, causing unwanted traffic and potentially waking up mobile devices without reason. If implemented by all clients, this will result in O(N²) messages to the MUC.
  2. Presence update: if the MUC service implements the legacy GC1.0 protocol, this will be treated as a join attempt, and the MUC will return the full list of occupants and full room history. The user's client will however miss partial history (other occupants leaving, potentially also messages), and this has the same drawbacks as the first solution.
  3. Private message to self: the client can send a MUC private message to itself. However, not all MUCs support / allow private messages, and there is no way to differentiate that from the error responses.
  4. Private IQ to self: the client can send an IQ to its own occupant JID. MUCs typically do not forbid those, and reflect the IQ request to the client (or another client of the same user). Once that client responds to the reflected IQ, the response is delivered to the initiating client as a sign of still being joined.
  5. Dedicated MUC IQ: a new type of IQ can be deployed to let the client explicitly check whether it is still joined to a MUC. However, this needs to be supported by the server, and the client needs to implement a fallback solution.

The private IQ is the most robust and traffic-efficient solution, and it does not rely on server support. The XMPP Ping (XEP-0199) [2] protocol is appropriate to use for this use case.

3.2 Performing a Self-Ping

After an adequate amount of silence from a given MUC (e.g. 15 minutes), or from all MUCs from a given service domain, a client should initiate a self-ping. If Juliet is joined as JuliC in the characters@chat.shakespeare.lit MUC, her client will send the following ping IQ:

Example 1. Self-Ping by Juliet's Client
<iq from='juliet@capulet.lit/client' id='s2c1' type='get'
  <ping xmlns='urn:xmpp:ping'/>

If Juliet's client is not joined, the MUC service will respond with a <not-acceptable> error. Thus, her client can automatically attempt a rejoin.

Example 2. Server Response to a Non-Occupant
<iq from='characters@chat.shakespeare.lit/JuliC' id='s2c1' type='error'
      to='juliet@capulet.lit/client' >
  <error type="cancel" by="characters@chat.shakespeare.lit">
    <not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />

If her client is joined, the IQ request will be forwarded to any one of Juliet's joined clients.

Example 3. Server Reflection of Ping
<iq from='characters@chat.shakespeare.lit/JuliC' id='c0ffee-s2c1' type='get'
      to='juliet@capulet.lit/somerandomclient' >
  <ping xmlns='urn:xmpp:ping'/>

Depending on the other client implementation and its connection status, the IQ will be responded to eventually, in one of these ways, as delivered to the "client" resource:

3.3 Server Optimization

The normal routing rules of the self-ping impose two round-trips: first the initial ping from the client to the MUC, then the reflection of the ping and its response (possibly to another client), and finally the response to the initial IQ. If the other client is experiencing network connectivity issues, which is often the case with mobile devices, the ping request might never be responded to.

Therefore, a MUC service supporting this protocol may directly respond to a occupant's Ping request to the occupant's own nickname, as opposed to routing it to any of the occupant's clients. A service implementing this optimization needs to advertise the http://jabber.org/protocol/muc#self-ping-optimization feature in the Service Discovery (XEP-0030) [5] disco#info response on the individual MUC room JIDs, and it MUST respond to a self-ping request as follows:

Example 4. MUC Service Advertises Self-Ping Optimization
<iq from='darkcave@chat.shakespeare.lit'
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <!-- ... -->
    <feature var='http://jabber.org/protocol/muc#self-ping-optimization'/>

4. Implementation Notes

In Multi-Session-Nick scenarios, where multiple clients of the same user are joined as the same occupant, it is possible that another client initiates a nickname change while a ping request is pending. In that case, the ping might be responded to with <item-not-found>.

A client should not perform a self-ping after initiating a nickname change, and before receiving the response to the nickname change from the service, as it is not yet clear whether the new nickname will be accepted.

If a client session is in hibernation (Stream Management (XEP-0198) [6]), the client should defer sending of self-ping requests until it is reconnected and re-authenticated.

5. Security Considerations

A MUC service implementation should not allow a non-occupant to obtain information about occupants. This is however true irregardless of implementing this specification.

6. IANA Considerations

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

7. XMPP Registrar Considerations

Include "http://jabber.org/protocol/muc#self-ping-optimization" as a valid feature in the Registry of Features.

Registry Submission
  <desc>Support for the MUC self-ping optimization</desc>

8. XML Schema

This document does not define any new XML structure requiring a schema.


Appendix A: Document Information

XMPP Standards Foundation
Standards Track
Last Updated
Approving Body
XMPP Council
XMPP Core, XEP-0001, Etc.
Superseded By
Short Name
Source Control

This document in other formats: XML  PDF

Appendix B: Author Information

Georg Lukas


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


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 <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

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 <https://xmpp.org/community/> 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. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.

2. XEP-0199: XMPP Ping <https://xmpp.org/extensions/xep-0199.html>.

3. XEP-0085: Chat State Notifications <https://xmpp.org/extensions/xep-0085.html>.

4. Different service implementations will send different responses to a client that's not joined. The recommended error code is <not-acceptable>, however some servers will respond with <not-allowed> or <bad-request> as well.

5. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

6. XEP-0198: Stream Management <https://xmpp.org/extensions/xep-0198.html>.

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

Appendix H: Revision History

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

  1. Version 1.1.0 (2019-09-25)
    Treat remote-server-not-found and remote-server-timeout like timeout errors (i.e. undecided).
  2. Version 1.0.1 (2019-07-30)
    Make feature string reference more clear
  3. Version 1.0.0 (2019-06-27)
    Move to Draft per Council Vote from 2019-02-06.
  4. Version 0.3.0 (2019-02-20)
    Incorporate council feedback: use @by on error elements
  5. Version 0.2.0 (2019-02-04)
    Incorporate feedback from Last Call.
  6. Version 0.1.0 (2018-08-31)
    Accepted by vote of Council on 2018-08-01.
    XEP Editor (jcb)
  7. Version 0.0.2 (2018-08-06)

    Add handling for another corner case, change title to Council’s liking

  8. Version 0.0.1 (2018-07-31)

    First draft.


Appendix I: Bib(La)TeX Entry

  title = {MUC Self-Ping (Schrödinger's Chat)},
  author = {Lukas, Georg},
  type = {XEP},
  number = {0410},
  version = {1.1.0},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-0410.html},
  date = {2018-07-31/2019-09-25},