Session Timers

Last modified by Timothée Jaussoin on 2020/03/24 15:07

Liblinphone supports the RFC 4028 - Session Timers.

From the RFC abstract

This document defines an extension to the Session Initiation Protocol (SIP). This extension allows for a periodic refresh of SIP sessions through a re-INVITE or UPDATE request. The refresh allows both user agents and proxies to determine whether the SIP session is still active. The extension defines two new header fields: Session-Expires, which conveys the lifetime of the session, and Min-SE, which conveys the minimum allowed value for the session timer.

How to use it

Session Timers within linphone can be enabled and configured using 4 variables:

  • The global toggle
  • The Session Timers value
  • The MinSE (Minimum Session Expires) value, that should always be lower or equal to the Session Timers value
  • The refresher default behavior

Enable the Session Timers feature

void linphone_core_set_session_expires_enabled(const LinphoneCore *lc, bool enable);

You can set the Session Timers value, in seconds

void linphone_core_set_session_expires_value(const LinphoneCore *lc, int expires); // not lower than MinSE

You can also set a minimal required value (MinSE), in seconds

void linphone_core_set_session_expires_min_value(const LinphoneCore *lc, int min); // Shoudn't be bellow 90

As well as the preferred behavior (following the UAS Behavior section of the RFC)

void linphone_core_set_session_expires_refresher_value(const LinphoneCore *lc, LinphoneSessionExpiresRefresher refresher);

Those variables can also be set in the config file using the following configuration variables: 

[sip]
session_expires_enabled=1
session_expires_value=100
session_expires_min_value=90
session_expires_refresher_value=2
; refresher value 0 = auto, 1 = uas, 2 = uac

Behavior

Based on the 4 configuration options above the library will then try to negotiate and refresh the session automatically.
It also supports UPDATE or INVITE based refresh regarding the other-end UPDATE support.