%ents; ]>
Best Practice for Closing Idle Streams This document specifies a best practice for closing an XML stream that is perceived to be idle. &LEGALNOTICE; 0190 Obsolete Informational Standards XMPP Core RFC 6120 N/A Carlo von Loesch lynX@jabber.getting.psyced.org lynX@ve.symlynX.com 1.1rc1 in progress, last updated 2012-02-08 psa

Changed status to Obsolete because it is superseded by RFC 6120.

1.0 2007-01-04 psa Per a vote of the XMPP Council, advanced status to Active. 0.1 2006-07-26 psa

Initial version.

0.0.2 2006-06-30 cvl Second draft. 0.0.1 2006-05-31 cvl First draft.

RFC 3920 describes several ways to terminate an XML stream, but does not always make a clear statement about which to use. This can lead to faulty implementations. In particular, closing a stream that has not been in use for a while is very often achieved using a connection-timeout error, then closing the socket. This can lead to loss of data. Therefore this document proposes a practice that will avoid such data loss.

Note: The recommendation described herein has been incorporated into &rfc6120;.

As shown in the basic "session" example in the Simplified Stream Examples (4.8 of RFC 3920), it is a valid transaction to close the outgoing stream by sending

]]>

then wait for the other entity to close its stream, like this:

]]>

and shut down the underlying TCP connection.

This will ensure that, should the other entity have transmitted any data, it will arrive and be processed before the TCP connection is terminated.

Special care MUST be taken that under no circumstance further packets may be written to the socket after the stream was closed, until the other side shuts down the socket.

On the outgoing TCP connection, an implementation MAY do a read-only shutdown of the socket, as long as the other side will safely be able to send its stream termination token.

In case the other entity fails to close the stream within a reasonable time frame, the entity that started the handshake is entitled to terminate the TCP connection. Since the stream has already been closed, it is correct not to produce an error condition.

Existing implementations should be updated to use the 'Handshake Stream Shutdown' strategy when shutting down streams that are no longer needed. This strategy is fully backwards-compatible and does not introduce any known communication problems.

This proposal introduces no new security aspects.

This proposal requires no interaction with &IANA;.

This proposal requires no interaction with the ®ISTRAR;.