forked from xsf/xeps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxep-0199.xml
303 lines (289 loc) · 13.9 KB
/
xep-0199.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>XMPP Ping</title>
<abstract>This specification defines an XMPP protocol extension for sending application-level pings over XML streams. Such pings can be sent from a client to a server, from one server to another, or end-to-end.</abstract>
&LEGALNOTICE;
<number>0199</number>
<status>Final</status>
<type>Standards Track</type>
<sig>Standards</sig>
<approver>Council</approver>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-0030</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>ping</shortname>
<schemaloc>
<url>http://www.xmpp.org/schemas/ping.xsd</url>
</schemaloc>
&stpeter;
<revision>
<version>2.0.1</version>
<date>2019-03-26</date>
<initials>o01eg</initials>
<remark>Fix incorrect IQ type in example (result => error)</remark>
</revision>
<revision>
<version>2.0</version>
<date>2009-06-03</date>
<initials>psa</initials>
<remark><p>Per a vote of the XMPP Council, advanced status to Final.</p></remark>
</revision>
<revision>
<version>1.0</version>
<date>2007-06-12</date>
<initials>psa</initials>
<remark><p>Per a vote of the XMPP Council, advanced status to Draft; XMPP Registrar issued urn:xmpp:ping namespace.</p></remark>
</revision>
<revision>
<version>0.5</version>
<date>2007-05-30</date>
<initials>psa</initials>
<remark><p>Clarified error handling and recommended against sending to bare JIDs.</p></remark>
</revision>
<revision>
<version>0.4</version>
<date>2007-05-21</date>
<initials>psa</initials>
<remark><p>Modified security considerations to ensure coherence of error handling between client and server.</p></remark>
</revision>
<revision>
<version>0.3</version>
<date>2007-05-07</date>
<initials>psa</initials>
<remark><p>Added use case for client pinging server; changed namespace to conform to XMPP Registrar requirements, with namespace to be issued upon advancement to Draft; added section on discovering support.</p></remark>
</revision>
<revision>
<version>0.2</version>
<date>2006-11-22</date>
<initials>psa</initials>
<remark><p>Changed IQ-set to IQ-get; clarified requirements; specified protocol description; added use cases.</p></remark>
</revision>
<revision>
<version>0.1</version>
<date>2006-11-21</date>
<initials>psa</initials>
<remark><p>Initial version.</p></remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>As specified in &xmppcore;, the XML streams used in XMPP are bound to TCP. Unfortunately, TCP connections can go down without the application (XMPP) layer knowing about it. The traditional approach to solving this issue has been to periodically send so-called "whitespace pings" over the XML stream. This document recommends a more XML-friendly approach, which can be used over more than one hop in the communication path (e.g., from one client to another) and can also be used with other bindings such as the &xep0124; method for which &xep0206; is the XMPP profile.</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<p>This specification addresses the following requirements:</p>
<ol start='1'>
<li>Determining the viability of an XML stream (i.e., its underlying binding) between a client and a server, or between two servers.</li>
<li>Determining end-to-end connectivity between any two XMPP entities (e.g., two clients).</li>
</ol>
<p>The number of "hops" for which the ping tests connectivity depends on how far the pinged entity is from the pinging entity, as shown in the following use cases. However, this specification does not provide per-hop information similar to that provided by the traceroute protocol (&rfc1393;); a future specification may define such functionality for XMPP.</p>
</section1>
<section1 topic='Protocol' anchor='protocol'>
<p>The XMPP ping protocol is extremely simple:</p>
<ol>
<li>The pinging entity sends an IQ-get containing a <ping/> element qualified by the 'urn:xmpp:ping' namespace.</li>
<li>The pinged entity returns either an IQ-result (if it supports the namespace) or an IQ-error (if it does not).</li>
</ol>
</section1>
<section1 topic='Use Cases' anchor='usecases'>
<section2 topic='Server-To-Client Pings' anchor='s2c'>
<p>One popular usage is for a server to test the viability of the underlying stream connection by pinging a connected client. This is done by sending an &IQ; get over the stream from the server to the client.</p>
<example caption="Ping"><![CDATA[
<iq from='capulet.lit' to='[email protected]/balcony' id='s2c1' type='get'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
]]></example>
<p>If the client supports the ping namespace, it MUST return an IQ-result, which functions as a "pong":</p>
<example caption="Pong"><![CDATA[
<iq from='[email protected]/balcony' to='capulet.lit' id='s2c1' type='result'/>
]]></example>
<p>If the client does not support the ping namespace, it MUST return a &unavailable; error:</p>
<example caption="Ping Not Supported"><![CDATA[
<iq from='[email protected]/balcony' to='capulet.lit' id='s2c1' type='error'>
<ping xmlns='urn:xmpp:ping'/>
<error type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>The other error conditions defined in <cite>RFC 6120</cite> could also be returned if appropriate.</p>
</section2>
<section2 topic='Client-To-Server Pings' anchor='c2s'>
<p>A client may also ping its server by sending an IQ-get over the stream between the two entities.</p>
<example caption="Ping"><![CDATA[
<iq from='[email protected]/balcony' to='capulet.lit' id='c2s1' type='get'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
]]></example>
<p>Note: The client MAY include a 'to' address of the client's bare JID &LOCALBARE;, in this instance "[email protected]" or MAY include no 'to' address (this signifies that the stanza shall be handled by the server on behalf of the connected user's bare JID, which in the case of &IQ; stanzas is equivalent to directing the IQ-get to the server itself).</p>
<p>If the server supports the ping namespace, it MUST return an IQ-result:</p>
<example caption="Pong"><![CDATA[
<iq from='capulet.lit' to='[email protected]/balcony' id='c2s1' type='result'/>
]]></example>
<p>If the server does not support the ping namespace, it MUST return a &unavailable; error:</p>
<example caption="Ping Not Supported"><![CDATA[
<iq from='capulet.lit' to='[email protected]/balcony' id='c2s1' type='error'>
<ping xmlns='urn:xmpp:ping'/>
<error type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>The other error conditions defined in <cite>RFC 6120</cite> could also be returned if appropriate.</p>
</section2>
<section2 topic='Server-To-Server Pings' anchor='s2s'>
<p>Pings can also be used to test a server-to-server connection. This is done by sending an IQ-get over the stream from one server to another.</p>
<example caption="Ping"><![CDATA[
<iq from='capulet.lit' to='montague.lit' id='s2s1' type='get'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
]]></example>
<p>If the other party to the stream supports the ping namespace, it MUST return an IQ-result:</p>
<example caption="Pong"><![CDATA[
<iq from='montague.lit' to='capulet.lit' id='s2s1' type='result'/>
]]></example>
<p>If the other party to the stream does not support the ping namespace, it MUST return a &unavailable; error:</p>
<example caption="Ping Not Supported"><![CDATA[
<iq from='montague.lit' to='capulet.lit' id='s2s1' type='error'>
<ping xmlns='urn:xmpp:ping'/>
<error type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>The other error conditions defined in <cite>RFC 6120</cite> could also be returned if appropriate.</p>
</section2>
<section2 topic='Client-to-Client Pings' anchor='e2e'>
<p>Pings can also be used for client-to-client (i.e., end-to-end) pings.</p>
<example caption="Ping"><![CDATA[
<iq from='[email protected]/home'
to='[email protected]/chamber'
type='get'
id='e2e1'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
]]></example>
<p>Note: The 'to' address should be a full JID &LOCALFULL;, since a ping sent to a bare JID &LOCALBARE; will be handled by the server on behalf of the client.</p>
<p>If the pinged entity supports the ping namespace, it SHOULD return an IQ-result:</p>
<example caption="Pong"><![CDATA[
<iq from='[email protected]/chamber'
to='[email protected]/home'
id='e2e1'
type='result'/>
]]></example>
<p>If the pinged entity does not support the ping namespace, it MUST return a &unavailable; error:</p>
<example caption="Ping Not Supported"><![CDATA[
<iq from='[email protected]/chamber'
to='[email protected]/home'
id='e2e1'
type='error'>
<ping xmlns='urn:xmpp:ping'/>
<error type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>The other error conditions defined in <cite>RFC 6120</cite> could also be returned if appropriate.</p>
</section2>
<section2 topic='Component-to-Client Pings' anchor='other'>
<p>Pings can also be used for component-to-client pings, for example from a &xep0045; component to a client.</p>
<example caption="Ping"><![CDATA[
<iq from='chat.shakespeare.lit'
to='[email protected]/chamber'
type='get'
id='comp1'>
<ping xmlns='urn:xmpp:ping'/>
</iq>
]]></example>
<p>Note: The 'to' address should be a full JID &LOCALFULL;, since a ping sent to a bare JID &LOCALBARE; will be handled by the server on behalf of the client.</p>
<p>If the pinged entity supports the ping namespace, it SHOULD return an IQ-result:</p>
<example caption="Pong"><![CDATA[
<iq from='[email protected]/chamber'
to='chat.shakespeare.lit'
id='comp1'
type='result'/>
]]></example>
<p>If the pinged entity does not support the ping namespace, <cite>RFC 6120</cite> requires it to return a &unavailable; error:</p>
<example caption="Ping Not Supported"><![CDATA[
<iq from='[email protected]/chamber'
to='chat.shakespeare.lit'
id='comp1'
type='error'>
<ping xmlns='urn:xmpp:ping'/>
<error type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>The other error conditions defined in <cite>RFC 6120</cite> could also be returned if appropriate.</p>
</section2>
</section1>
<section1 topic='Determining Support' anchor='support'>
<p>If an entity supports the XMPP Ping protocol, it MUST report that fact by including a service discovery feature of "urn:xmpp:ping" in response to a &xep0030; information request:</p>
<example caption="Service Discovery information request"><![CDATA[
<iq type='get'
from='[email protected]/balcony'
to='capulet.lit'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
<example caption="Service Discovery information response"><![CDATA[
<iq type='result'
from='capulet.lit'
to='[email protected]/balcony'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='urn:xmpp:ping'/>
...
</query>
</iq>
]]></example>
<p>In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.</p>
</section1>
<section1 topic='Implementation Notes' anchor='impl'>
<p>Some XMPP clients do not respond to IQ stanzas containing unsupported payloads. Although this is in violation of &xmppcore;, this behavior can result in disconnection of clients that are in fact actively connected to the server.</p>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<p>If a server receives a ping request directed to a full JID &LOCALFULL; associated with a registered account but there is no connected resource matching the 'to' address, <cite>RFC 6120</cite> requires it to reply with a &unavailable; error and set the 'from' address of the IQ-error to the full JID provided in the 'to' address of the ping request. If a connected resource receives a ping request but it does not want to reveal its network availability to the sender for any reason (e.g., because the sender is not authorized to know the connected resource's availability), then it too MUST reply with a &unavailable; error. This consistency between the server response and the client response helps to prevent presence leaks.</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>No interaction with &IANA; is necessary as a result of this document.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Protocol Namespaces' anchor='registrar-ns'>
<p>The ®ISTRAR; includes "urn:xmpp:ping" in its registry of protocol namespaces (see &NAMESPACES;).</p>
</section2>
</section1>
<section1 topic='XML Schema' anchor='schema'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
xmlns:xs='http://www.w3.org/2001/XMLSchema'
targetNamespace='urn:xmpp:ping'
xmlns='urn:xmpp:ping'
elementFormDefault='qualified'>
<xs:annotation>
<xs:documentation>
The protocol documented by this schema is defined in
XEP-0199: http://www.xmpp.org/extensions/xep-0199.html
</xs:documentation>
</xs:annotation>
<xs:element name='ping' type='empty'/>
<xs:simpleType name='empty'>
<xs:restriction base='xs:string'>
<xs:enumeration value=''/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
]]></code>
</section1>
</xep>