Terminating a Session
This section describes the procedures for terminating a session
established by SIP. The state of the session and the state of the
dialog are very closely related. When a session is initiated with an
INVITE, each 1xx or 2xx response from a distinct UAS creates a
dialog, and if that response completes the offer/answer exchange, it
also creates a session. As a result, each session is "associated"
with a single dialog - the one which resulted in its creation. If an
initial INVITE generates a non-2xx final response, that terminates
all sessions (if any) and all dialogs (if any) that were created
through responses to the request. By virtue of completing the
transaction, a non-2xx final response also prevents further sessions
from being created as a result of the INVITE. The BYE request is
used to terminate a specific session or attempted session. In this
case, the specific session is the one with the peer UA on the other
side of the dialog. When a BYE is received on a dialog, any session
associated with that dialog SHOULD terminate. A UA MUST NOT send a
BYE outside of a dialog. The caller's UA MAY send a BYE for either
confirmed or early dialogs, and the callee's UA MAY send a BYE on
confirmed dialogs, but MUST NOT send a BYE on early dialogs.