Im wondering if this is expected Asterisk/PJSIP behavior.
Asterisk ------> PBX
INVITE (Session-Expire: 200)
PBX -----> Asterisk
200OK (Session-Expire: 300; refresher=uas)
After ~200s PJSIP sends BYE with message:
No session refresh received after 168s (expiration period=200), stopping session now!
I found PJSIP code that triggers timer:
/* Send BYE if no refresh received until this timer fired, delay
- is the minimum of 32 seconds and one third of the session interval
- before session expiration.
delay.sec = timer->setting.sess_expires - timer->setting.sess_expires/3;
delay.sec = PJ_MAX((long)timer->setting.sess_expires-32, delay.sec);
Why session is reduced(32s), I guess it should be 32 greater to give UAS chance to send refresh.
What do you think?
It’s in pjproject/pjsip/src/pjsip-ua/sip_timer.c. There is also a comment:
||/* Update SE. Session-Expires in response cannot be lower than Min-SE.|
|| * Session-Expires in response can only be equal or lower than in |
|| * request.|
if (se_hdr && se_hdr->sess_expires <= inv->timer->setting.sess_expires && se_hdr->sess_expires >= inv->timer->setting.min_se)
/* Good SE from remote, update local SE */
inv->timer->setting.sess_expires = se_hdr->sess_expires;
so on processing response, PJSIP takes own timer value from INVITE, and change it only if value from response is lower. Is that correct?
I checked RFC 4028 and it looks like it’s correct:
Similarly, if the side not performing refreshes does not receive a
session refresh request before the session expiration, it SHOULD send
a BYE to terminate the session, slightly before the session
expiration. The minimum of 32 seconds and one third of the session
interval is RECOMMENDED.
Is this 200 or 300? Session-Expire is obviously wrong. Generally one should copy pjsip set logger on output electronically, rather than re-keying.
The PBX replying with 300, to a request with 200, would be a protocol violation.
PBX (UAS) sends response with Session-Expire value greater then UAC Session-Expire.
Protocol violation! If it considers the timer offered too short, it must reject it with 422. It must return the original value or a lesser one. RFC 4028: Session Timers in the Session Initiation Protocol (SIP) (second through fourth paragraph).