PJSIP session timers refresher role neglected or confused?

We have been noticing that some of the incoming calls to our Asterisk (13.13-cert9) server are being disconnected exactly after 88 seconds. This does not seem to happen for all calls; it appears to be triggered randomly.

After investigating the SIP message exchange between our asterisk and the trunk it is receiving calls from, we suspect that the way Asterisk handles session timers is the cause of the problem:

  1. The INVITE from the trunk has Session-Expires: 120
  2. When the call is answered asterisk sends out an UPDATE which has
    Session-Expires: 120;refresher=uas
  3. The UPDATE is immediately followed by 200 OK which also has
    Session-Expires: 120;refresher=uas

The trunk assumes no responsibility for refreshing as our asterisk has indicated to be the refresher by setting refresher=uas in the 200 OK sent to the trunk. However, our asterisk does not seem to send any RE-INVITE or UDPATE messages. Instead it appears to be waiting for those messages from the trunk.

After 88 seconds our asterisk sends out a BYE ending the session. We believe the 88 seconds timeout comes from the session expiry timeout minus 32 seconds (hard-coded minimum in source code): 120 - 32 = 88

In sessions where asterisk responds with 200 OK and refresher=uac the calls continues as the trunk refreshes by sending UPDATE messages every 60 seconds. We do not know how asterisk chooses between uas and uac for the refresher. It appears to be randomly chosen and the calls where it chooses uas fail.

We are using PJSIP for SIP protocol support. The configuration for PJSIP endpoints does not have any option that configures asterisk to respond with either refresher=uac or refresher=uas. For now, we had to disable the timers by setting timers=no there, but our trunk provider insists we have session timers to control our call costs in case of broken network connectivity.

Is there any way to get PJSIP to work correctly with the session timers?

I’d suggest using the latest version of Asterisk first with bundled, as I vaguely recall that there was a problem uncovered with session timers either on our side or in PJSIP itself. Afterwards if it still occurs the full SIP trace would be needed.


Is it fixed in the latest certified LTS, 13.18-cert3? Or should we try out the latest, 15.3.0?

You can try the latest certified, but unless you have a support agreement with Digium and go through the support system then any fix that may occur will not go into the certified branch.

The latest version of 13 mainline is 13.20.0, which is LTS.

Hi, we saw similar behaviour today with asterisk 13.20.0. An incoming call was terminated after exactly 90 seconds, and like before asterisk has not sent any UPDATES when it has chosen to refresh by setting refresher=uas

How can I provide you the SIP traces?

I’d suggest filing an issue[1] with the traces attached and complete information about how to reproduce it.

[1] https://issues.asterisk.org/jira