PDA

View Full Version : How is a client crash communicated to the XMPP server?


santhosh.kulandaiyan
06-02-2008, 10:25 AM
Hi,
I would like to discuss about what happens when an XMPP client crashes and how this information is communicated to the server..

I have a server S and 2 clients C1 and C2 connected to the server. C1 has C2 in its roster list and C2 has C1 in its roster list.

If C1 gracefully logs out, then an iq stanza of type unavailable is sent to the server and the server broadcasts that stanza to all JIDs which have a subscription of from or both.

However, I have been trying to search for what happens when the client crashes (or exits ungracefully). I havent arrived at the answer yet. Here is what RFC 3291 says :

"5.1.5. Unavailable Presence

Before ending its session with a server, a client SHOULD gracefully become
unavailable by sending a final presence stanza that possesses no 'to'
attribute and that possesses a 'type' attribute whose value is
"unavailable" (optionally, the final presence stanza MAY contain one or
more <status/> elements specifying the reason why the user is no longer
available). However, the user's server MUST NOT depend on receiving final
presence from an available resource, since the resource may become
unavailable unexpectedly or may be timed out by the server. If one of the
user's resources becomes unavailable for any reason (either gracefully or
ungracefully), the user's server MUST broadcast unavailable presence to
all contacts (1) that are in the user's roster with a subscription type of
"from" or "both", (2) to whom the user has not blocked outbound presence,
and (3) from whom the server has not received a presence error during the
user's session; the user's server MUST also send that unavailable presence
stanza to any of the user's other available resources, as well as to any
entities to which the user has sent directed presence during the user's
session for that resource (if the user has not yet sent directed
unavailable presence to that entity). Any presence stanza with no 'type'
attribute and no 'to' attribute that is sent after sending directed
unavailable presence or broadcasted unavailable presence MUST be
broadcasted by the server to all subscribers. "

Do we interpret that as : "the server will 'somehow' know that the client has crashed and then publish the unavailable stanzas to everyone subscribed to that JID ?

Please clarify.. :-)

-santhosh

Michal 'vorner' Vaner
06-02-2008, 10:38 AM
Hello

On Mon, Jun 02, 2008 at 10:25:02AM +0200, JabberForum wrote:
> However, I have been trying to search for what happens when the
> client crashes (or exits ungracefully). I havent arrived at the answer
> yet. Here is what RFC 3291 says :

The OS closes the connection. It is enough.

--
XML is like violence. If it doesn't solve your problem, use more.

Michal 'vorner' Vaner

_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
_______________________________________________

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEABECAAYFAkhDsR0ACgkQ7/oWwynB3bIZ7gCeOrolC3EuSC3ol+mpIzKYDAnI
XsoAn3FSfewB+SWAsazL4yZ4cTprqTzl
=mufd
-----END PGP SIGNATURE-----

Jonathan Dickinson
06-02-2008, 11:00 AM
Good question.

You will find that the Coversant XMPP communicator does not send a <presence type="unavailable"/> stanza when it logs out. From what I can tell is that most servers will do that on behalf of the client: it caused me a few minutes of debugging :).

If you want to tell when the client disconnects unexpectedly from another client (e.g. if you have a contact that represents your server availability or something) you could do something like:

<presence type="available">
...
<!-- NB: No 'graceful' element -->
</presence>

<presence type="unavailable">
...
<graceful xmlns="http://www.tempuri.org/xmpp.org/graceful">
</presence>

If you receive a stanza without the graceful element you can be sure that the client quit unexpectedly (server sent 'unavailable' on behalf of the client).

This raises another important question: most servers AND clients are not XMPP compliant. It is very strange and annoying. Should I take a 'tough luck, you should behave properly' approach to non-compliant clients and servers?

> -----Original Message-----
> From: jdev-bounces (AT) jabber (DOT) org [mailto:jdev-bounces (AT) jabber (DOT) org] On Behalf Of
> JabberForum
> Sent: 02 June 2008 10:25 AM
> To: jdev (AT) jabber (DOT) org
> Subject: [jdev] How is a client crash communicated to the XMPP server?
>
>
> Hi,
> I would like to discuss about what happens when an XMPP client crashes
> and how this information is communicated to the server..
>
> I have a server S and 2 clients C1 and C2 connected to the server. C1
> has C2 in its roster list and C2 has C1 in its roster list.
>
> If C1 gracefully logs out, then an iq stanza of type unavailable is
> sent to the server and the server broadcasts that stanza to all JIDs
> which have a subscription of from or both.
>
> However, I have been trying to search for what happens when the
> client crashes (or exits ungracefully). I havent arrived at the answer
> yet. Here is what RFC 3291 says :
>
> "5.1.5. Unavailable Presence
>
> Before ending its session with a server, a client SHOULD gracefully
> become
> unavailable by sending a final presence stanza that possesses no 'to'
> attribute and that possesses a 'type' attribute whose value is
> "unavailable" (optionally, the final presence stanza MAY contain one or
>
> more <status/> elements specifying the reason why the user is no longer
>
> available). *However, the user's server MUST NOT depend on receiving
> final
> presence from an available resource, since the resource may become
> unavailable unexpectedly or may be timed out by the server. If one of
> the
> user's resources becomes unavailable for any reason (either gracefully
> or
> ungracefully), the user's server MUST broadcast unavailable presence to
>
> all contacts *(1) that are in the user's roster with a subscription
> type of
> "from" or "both", (2) to whom the user has not blocked outbound
> presence,
> and (3) from whom the server has not received a presence error during
> the
> user's session; the user's server MUST also send that unavailable
> presence
> stanza to any of the user's other available resources, as well as to
> any
> entities to which the user has sent directed presence during the user's
>
> session for that resource (if the user has not yet sent directed
> unavailable presence to that entity). Any presence stanza with no
> 'type'
> attribute and no 'to' attribute that is sent after sending directed
> unavailable presence or broadcasted unavailable presence MUST be
> broadcasted by the server to all subscribers. "
>
> Do we interpret that as : "the server will 'somehow' know that the
> client has crashed and then publish the unavailable stanzas to everyone
> subscribed to that JID ?
>
> Please clarify.. :-)
>
> -santhosh
>
>
> --
> santhosh.kulandaiyan
> ------------------------------------------------------------------------
> santhosh.kulandaiyan's Profile:
> http://www.jabberforum.org/member.php?userid=16912
> View this thread: http://www.jabberforum.org/showthread.php?t=200
>
> _______________________________________________
> JDev mailing list
> FAQ: http://www.jabber.org/discussion-lists/jdev-faq
> Forum: http://www.jabberforum.org/forumdisplay.php?f=20
> Info: http://mail.jabber.org/mailman/listinfo/jdev
> Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
> _______________________________________________
_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
_______________________________________________

santhosh.kulandaiyan
06-03-2008, 09:15 AM
>>If you want to tell when the client disconnects unexpectedly from another >>client (e.g. if you have a contact that represents your server availability or >>something) you could do something like:

Is there someway to figure out what happens at the server when a client crashes. Is any iq stanza sent to server (i doubt this would happen, because the client has crashed) or would the xmpp server come to know that by polling the status of the underlying tcp connection/socket?

thanks
santhosh

Jonathan Dickinson
06-03-2008, 02:41 PM
Unfortunately not all clients are 100% XMPP compliant. I am certain that most will give you a </stream:stream> at the end: so if a client disconnects without that they /should/ have quit unexpectedly.

Conversant XMPP Communicator:

</stream:stream>

Coccinella:

<presence type='unavailable'/>

</stream:stream>

As you can see Coccinella behaves as a client should, but both send the </stream:stream> so you should be able to tell with that.

So:

Client sends </stream:stream>
o Disconnect client
o Client disconnected normally
Client disconnects
o Abandon client
o Client disconnected unexpectedly

HTH

> -----Original Message-----
> From: jdev-bounces (AT) jabber (DOT) org [mailto:jdev-bounces (AT) jabber (DOT) org] On Behalf Of
> JabberForum
> Sent: 03 June 2008 09:16 AM
> To: jdev (AT) jabber (DOT) org
> Subject: Re: [jdev] How is a client crash communicated to the XMPP server?
>
>
> >>If you want to tell when the client disconnects unexpectedly from
> another >>client (e.g. if you have a contact that represents your server
> availability or >>something) you could do something like:
>
> Is there someway to figure out what happens at the server when a client
> crashes. Is any iq stanza sent to server (i doubt this would happen,
> because the client has crashed) or would the xmpp server come to know
> that by polling the status of the underlying tcp connection/socket?
>
> thanks
> santhosh
>
>
> --
> santhosh.kulandaiyan
> ------------------------------------------------------------------------
> santhosh.kulandaiyan's Profile:
> http://www.jabberforum.org/member.php?userid=16912
> View this thread: http://www.jabberforum.org/showthread.php?t=200
>
> _______________________________________________
> JDev mailing list
> FAQ: http://www.jabber.org/discussion-lists/jdev-faq
> Forum: http://www.jabberforum.org/forumdisplay.php?f=20
> Info: http://mail.jabber.org/mailman/listinfo/jdev
> Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
> _______________________________________________
_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
_______________________________________________

Peter Saint-Andre
06-03-2008, 05:20 PM
On 06/03/2008 1:15 AM, JabberForum wrote:
>>> If you want to tell when the client disconnects unexpectedly from
> another >>client (e.g. if you have a contact that represents your server
> availability or >>something) you could do something like:
>
> Is there someway to figure out what happens at the server when a client
> crashes. Is any iq stanza sent to server (i doubt this would happen,
> because the client has crashed) or would the xmpp server come to know
> that by polling the status of the underlying tcp connection/socket?

If a client disconnects gracefully, it will send </stream:stream> and
close the TCP connection.

If a client disconnected ungracefully, it will send nothing, so the
server will need to poll the TCP connection periodically (if the
connection is idle); this is typically done using so-called "whitespace
pings" as described here:

http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-05.html#streams-close-idle

Peter

--
Peter Saint-Andre
https://stpeter.im/


_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
_______________________________________________

santhosh.kulandaiyan
06-09-2008, 08:27 AM
On 06/03/2008 1:15 AM, JabberForum wrote:[color=blue][color=green][color=darkred]
If a client disconnected ungracefully, it will send nothing, so the
server will need to poll the TCP connection periodically (if the
connection is idle); this is typically done using so-called "whitespace
pings" as described here:

http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-05.html#streams-close-idle



Thanks Peter for the comments. The RFC states that the TCP polling interval is configurable.

<snip>
The time between such "whitespace pings" is a matter of implementation and local service policy; however, it is RECOMMENDED that these pings be sent not more than once every 60 seconds.
</snip>

Is there a default polling interval ?.. or is that also dependent on the xmpp server implementation?

I have been working with Jabber XCP server and i only found a "polling director" component which has a session timeout field which is nothing but ---> "the number of seconds after which the server terminates the session if the client has not sent a poll request."

I think this is purely at (the higher) xmpp level and does not talk about TCP polling, or does it ..?

Thanks
Santhosh

Peter Saint-Andre
06-09-2008, 04:54 PM
On 06/09/2008 12:27 AM, JabberForum wrote:
> Peter Saint-Andre;727 Wrote:
>> On 06/03/2008 1:15 AM, JabberForum
>> wrote:[color=blue][color=green][color=darkred]
>> If a client disconnected ungracefully, it will send nothing, so the
>> server will need to poll the TCP connection periodically (if the
>> connection is idle); this is typically done using so-called
>> "whitespace
>> pings" as described here:
>>
>> http://tinyurl.com/6kjqwt
>>
>>
>
> Thanks Peter for the comments. The RFC states that the TCP polling
> interval is configurable.
>
> <snip>
> The time between such "whitespace pings" is a matter of implementation
> and local service policy; however, it is RECOMMENDED that these pings be
> sent not more than once every 60 seconds.
> </snip>
>
> Is there a default polling interval ?.. or is that also dependent on
> the xmpp server implementation?

That depends on the server implementation.

> I have been working with Jabber XCP server and i only found a "polling
> director" component which has a session timeout field which is nothing
> but ---> "the number of seconds after which the server terminates the
> session if the client has not sent a poll request."
>
> I think this is purely at (the higher) xmpp level and does not talk
> about TCP polling, or does it ..?

This is probably a whitespace ping at the TCP level (not an "XMPP Ping"
via XEP-01999), but you could contact the Jabber XCP developers for
further information.

Peter

--
Peter Saint-Andre
https://stpeter.im/


_______________________________________________
JDev mailing list
FAQ: http://www.jabber.org/discussion-lists/jdev-faq
Forum: http://www.jabberforum.org/forumdisplay.php?f=20
Info: http://mail.jabber.org/mailman/listinfo/jdev
Unsubscribe: JDev-unsubscribe (AT) jabber (DOT) org
_______________________________________________