Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected BYE, 408 "Session timeout" with Aastra 400 #284

Open
BrianMiller793 opened this issue Jan 7, 2025 · 2 comments
Open

Unexpected BYE, 408 "Session timeout" with Aastra 400 #284

BrianMiller793 opened this issue Jan 7, 2025 · 2 comments

Comments

@BrianMiller793
Copy link

Version: FreeSWITCH version: 1.10.12-release+git~20240802T210227Z~a88d069d6f~64bit (git a88d069 2024-08-02 21:02:27Z 64bit)
Sofia: sofia-sip-1.13.17

An Aastra 400 calls FreeSWITCH as a client. Less than 120 seconds later, FreeSWITCH hangs up with an unexpected BYE, and "Session timeout" for the reason. The problem only occurs when the UAC is outside the local network.

I have reproduced this using a test script, and the error happens only when the NAT is in use from an external address. To reproduce the error under test, I connect a Raspberry PI through my cell phone, and then run a Python Behave script against my test server. The error will not reproduce when the UAC is on the same network as the server.

From fs_cli: nua_session.c:1564 nua_session_usage_refresh() nua(0x7a56ec0509a0): session almost expired, sending BYE before timeout.

In mod_sofia.c, I found that commenting out the check for Aastra in sofia_receive_message() (line 2071) allows the call to complete normally.

What sets off the unexpected action is a 200 OK to an UPDATE, with "Session-Expires: 1800;refresher=uas". If Session-Expires does not have the "refresher", then the premature BYE does not occur.

Session Initiation Protocol (200)
Status-Line: SIP/2.0 200 OK
Message Header
    Via: SIP/2.0/TCP 64.19.65.25:5080;rport=5080;branch=z9hG4bKe3UKBgKt3Bm8K;received=64.19.65.25
    To: "Osthoff" <sip:wunderbaum@littletrees>;tag=AI1E037B1410C9A99B
    From: <sip:7253@littletrees>;tag=yXt8Dy3e1QB9H
    Call-ID: AI15C12F081C97F2D2_00:08:5d:97:7d:12
    CSeq: 90289035 UPDATE
    Contact: <sip:[email protected]:5060;transport=tcp>
    Allow-Events: presence,dialog,message-summary,refer
    Allow: ACK,BYE,CANCEL,INVITE,NOTIFY,OPTIONS,PUBLISH,UPDATE,REFER
    User-Agent: Aastra 400
    P-Preferred-Identity: "Osthoff" <sip:[email protected]>
    Require: timer
    Session-Expires: 1800;refresher=uas
    Supported: timer
    Content-Type: application/sdp
    Content-Length: 234
Message Body
    Session Description Protocol
        Session Description Protocol Version (v): 0
        Owner/Creator, Session Id (o): aastra400 48971799 48971800 IN IP4 192.168.1.225
        Session Name (s): call
        Connection Information (c): IN IP4 192.168.1.225
        Time Description, active time (t): 0 0
        Media Description, name and address (m): audio 5004 RTP/AVP 8 0 101
        Media Attribute (a): rtpmap:8 PCMA/8000
        Media Attribute (a): rtpmap:0 PCMU/8000
        Media Attribute (a): rtpmap:101 telephone-event/8000
        Media Attribute (a): fmtp:101 0-15
        Media Attribute (a): ptime:20
@BrianMiller793
Copy link
Author

I have attached console logs and captures of the problem.

BehaveVanillaReproConsole.txt.gz
BehaveVanillaRepro.pcapng.gz
AastraFail.pcap.gz

@BrianMiller793
Copy link
Author

From my investigation, it looks like the session timer parameters may not be set correctly during initialization:

nua_session.c:1545 nua_session_usage_refresh() nh=0x7521e00032d0, ss=0x75223c02ba50, callstate=ready
nua_session.c:1546 nua_session_usage_refresh() ss_timer: interval=120, refresher=1, timer_set=1
nua_session.c:1548 nua_session_usage_refresh() local: expires=90, defaults=0, min_se=120, refresher=1, supported=1, require=0
nua_session.c:1550 nua_session_usage_refresh() remote: expires=120, defaults=0, min_se=0, refresher=1, supported=1, require=0

and

nua_session.c:1545 nua_session_usage_refresh() nh=0x75223c028da0, ss=0x75223c025be0, callstate=ready
nua_session.c:1546 nua_session_usage_refresh() ss_timer: interval=120, refresher=2, timer_set=1
nua_session.c:1548 nua_session_usage_refresh() local: expires=90, defaults=0, min_se=120, refresher=2, supported=1, require=0
nua_session.c:1550 nua_session_usage_refresh() remote: expires=1800, defaults=0, min_se=0, refresher=2, supported=1, require=1
nua_session.c:1574 nua_session_usage_refresh() nua(0x75223c028da0): session almost expired, sending BYE before timeout.

The 200 OK response doesn't have a Min-SE header, so that seems to affect timer behavior. I added code to set the Min-SE value from Session-Expires if Min-SE isn't present.

diff --git a/libsofia-sip-ua/nua/nua_session.c b/libsofia-sip-ua/nua/nua_session.c
index b9bd1ee..214d135 100644
--- a/libsofia-sip-ua/nua/nua_session.c
+++ b/libsofia-sip-ua/nua/nua_session.c
@@ -4427,6 +4427,8 @@ void session_timer_store(struct session_timer *t,
 
   if (sip->sip_min_se)
     t->remote.min_se = sip->sip_min_se->min_delta;
+  else if (x)
+    t->remote.min_se = x->x_delta;
 }
 
 /** Add timer feature and Session-Expires/Min-SE headers to request/response

The issue seems to be fixed with that change.

nua_session.c:1545 nua_session_usage_refresh() nh=0x7ce048000dd0, ss=0x7ce0a002b7a0, callstate=ready
nua_session.c:1546 nua_session_usage_refresh() ss_timer: interval=120, refresher=1, timer_set=1
nua_session.c:1548 nua_session_usage_refresh() local: expires=90, defaults=0, min_se=120, refresher=1, supported=1, require=0
nua_session.c:1550 nua_session_usage_refresh() remote: expires=120, defaults=0, min_se=120, refresher=1, supported=1, require=0

I'm doing further testing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant