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:
- The
INVITEfrom the trunk hasSession-Expires: 120 - When the call is answered asterisk sends out an
UPDATEwhich has
Session-Expires: 120;refresher=uas - The
UPDATEis immediately followed by200 OKwhich 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?