<p></p>

<h3>Description</h3>
<p>Kamailio not updating record-route value stored in redis (topos module) during re-invite</p>
<p>config:</p>
<p>modparam("ndb_redis", "server", "name=srv1;addr=localhost;port=6379;db=1")<br>
modparam("topos", "storage", "redis")<br>
modparam("topos_redis", "serverid", "srv1")<br>
modparam("topos", "branch_expire", 300)<br>
modparam("topos", "dialog_expire", 10800)<br>
modparam("topos", "sanity_checks", 1)<br>
modparam("topos", "clean_interval", 20)</p>

<h3>Troubleshooting</h3>
<h4>Reproduction</h4>
<ol>
<li>Initial Invite from Kamailio to Server1 (Transaction complete)</li>
<li>Server1 is down</li>
<li>Re-invite from Kamailio to Server2</li>
<li>200 OK contains record-route of Server2</li>
<li>ACK is forwarded to Server1 (record-route stored in dialog Key still has old record-route)</li>
</ol>

<h4>Debugging Data</h4>
<p>b_rr value remains same even after 200 OK for re-invite has a different record-route</p>
<pre><code>**redis data after Initial Invite:**
127.0.0.1:6379[1]> hgetall d:z:atpsh-5fb50084-5b44-1
 1) "b_rr"
 2) "<sip:10.130.74.130;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>"
 3) "as_contact"
 4) "<sip:atpsh-5fb50084-5b44-1@3.225.0.56>"
 5) "s_rr"
 6) "<sip:3.225.0.56;lr;ftag=11368SIPpTag091;nat=yes>"
 7) "b_tag"
 8) "2"
 9) "bs_contact"
10) "<sip:btpsh-5fb50084-5b44-1@3.225.0.56>"
11) "rectime"
12) "1605698163"
13) "a_tag"
14) "11368SIPpTag091"
15) "s_cseq"
16) "1"
17) "s_method"
18) "INVITE"
19) "b_contact"
20) "sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1"
21) "a_callid"
22) "1-11368@10.130.74.171"
23) "a_uuid"
24) "atpsh-5fb50084-5b44-1"
25) "b_uuid"
26) "btpsh-5fb50084-5b44-1"
27) "a_contact"
28) "sip:sipp@10.130.74.171:5060;alias=10.130.74.171~5060~1"
29) "iflags"
30) "2"

**redis data after re-Invite:**

127.0.0.1:6379[1]> hgetall d:z:atpsh-5fb50084-5b44-1
 1) "b_rr"
 2) "<sip:10.130.74.130;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>"
 3) "as_contact"
 4) "<sip:atpsh-5fb50084-5b44-1@3.225.0.56>"
 5) "s_rr"
 6) "<sip:3.225.0.56;lr;ftag=11368SIPpTag091;nat=yes>"
 7) "b_tag"
 8) "2"
 9) "bs_contact"
10) "<sip:btpsh-5fb50084-5b44-1@3.225.0.56>"
11) "rectime"
12) "1605698163"
13) "a_tag"
14) "11368SIPpTag091"
15) "s_cseq"
16) "1"
17) "s_method"
18) "INVITE"
19) "b_contact"
20) "sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1;alias=10.130.72.145~5060~1"
21) "a_callid"
22) "1-11368@10.130.74.171"
23) "a_uuid"
24) "atpsh-5fb50084-5b44-1"
25) "b_uuid"
26) "btpsh-5fb50084-5b44-1"
27) "a_contact"
28) "sip:sipp@10.130.74.171:5060;alias=10.130.74.171~5060~1"
29) "iflags"
30) "2"

</code></pre>
<p>same issue seen for a_rr value in redis.</p>

<h4>Log Messages</h4>

<pre><code>(paste your log messages here)
</code></pre>
<h4>SIP Traffic</h4>
<pre><code>**Initial Invite Incoming:**
INVITE sip:+919535346001@10.130.72.228:5060 SIP/2.0
Via: SIP/2.0/UDP 10.130.74.171:5060;branch=z9hG4bK-11368-1-0
From: sipp <sip:9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>
Call-ID: 1-11368@10.130.74.171
CSeq: 1 INVITE
Contact: sip:sipp@10.130.74.171:5060
Supported: timer, 100rel , replaces
Max-Forwards: 70
Subject: Performance Test
Content-Type: application/sdp
Content-Length:   208


**Initial Invite outgoing:**
INVITE sip:919535346001@10.130.74.130:5060 SIP/2.0
Via: SIP/2.0/UDP 3.225.0.56:5060;branch=z9hG4bK7afa.d2d1cbb7e8c7a99adf854ba4d854a467.0
From: sipp <sip:9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>
Call-ID: 1-11368@10.130.74.171
CSeq: 1 INVITE
Supported: timer, 100rel , replaces
Max-Forwards: 69
Subject: Performance Test
Content-Type: application/sdp
Content-Length:   208
Contact: <sip:btpsh-5fb50084-5b44-1@3.225.0.56>

**response incoming**
SIP/2.0 200 OK
From: sipp <sip:+9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 1 INVITE
Content-Type: application/sdp
Content-Length:   162
Via: SIP/2.0/UDP 3.225.0.56:5060;rport=5060;received=10.130.72.228;branch=z9hG4bK7afa.d2d1cbb7e8c7a99adf854ba4d854a467.0
Contact: <sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1>
Record-Route: <sip:10.130.74.130;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>
Accept: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE

**response outgoing**
SIP/2.0 200 OK
From: sipp <sip:+9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 1 INVITE
Content-Type: application/sdp
Content-Length:   162
Accept: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE
Via: SIP/2.0/UDP 10.130.74.171:5060;rport=5060;branch=z9hG4bK-11368-1-0
Contact: <sip:atpsh-5fb50084-5b44-1@3.225.0.56>


**ACK Incoming**
ACK sip:atpsh-5fb50084-5b44-1@3.225.0.56 SIP/2.0
Via: SIP/2.0/UDP 10.130.74.171:5060;branch=z9hG4bK-11368-1-5
From: sipp <sip:sipp@10.130.74.171:5060>;tag=11368SIPpTag091
To: sut <sip:service@10.130.72.228:5060>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 1 ACK
Contact: sip:sipp@10.130.74.171:5060
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0

**ACK outgoing**
ACK sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1 SIP/2.0
Via: SIP/2.0/UDP 3.225.0.56:5060;branch=z9hG4bK7afa.5b31cae6abf9db84bc4197496dd24951.0
From: sipp <sip:sipp@10.130.74.171:5060>;tag=11368SIPpTag091
To: sut <sip:service@10.130.72.228:5060>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 1 ACK
Max-Forwards: 69
Subject: Performance Test
Content-Length: 0
Route: <sip:10.130.74.130;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>
Contact: <sip:btpsh-5fb50084-5b44-1@3.225.0.56>


**re-invite incoimg**
INVITE sip:atpsh-5fb50084-5b44-1@3.225.0.56 SIP/2.0
Via: SIP/2.0/UDP 10.130.74.171:5060;branch=z9hG4bK-11368-1-7
From: sipp <sip:9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 INVITE
Contact: sip:sipp@10.130.74.171:5060
Supported: timer, 100rel , replaces
Max-Forwards: 70
Subject: Performance Test
Content-Type: application/sdp
Content-Length:   208

**re-invite outgoing**
INVITE sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1 SIP/2.0
Via: SIP/2.0/UDP 3.225.0.56:5060;branch=z9hG4bK4afa.168b5e5898c0e5586bbbe73c71d2f089.1
From: sipp <sip:9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 INVITE
Supported: timer, 100rel , replaces
Max-Forwards: 69
Subject: Performance Test
Content-Type: application/sdp
Content-Length:   208
Route: <sip:10.130.72.145;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>
Contact: <sip:btpsh-5fb50084-5b44-1@3.225.0.56>

**response incoming**
SIP/2.0 200 OK
From: sipp <sip:+9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 INVITE
Content-Type: application/sdp
Content-Length:   162
Via: SIP/2.0/UDP 3.225.0.56:5060;rport=5060;received=10.130.72.228;branch=z9hG4bK4afa.168b5e5898c0e5586bbbe73c71d2f089.1
Contact: <sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1>
Record-Route: <sip:10.130.72.145;lr;ftag=11368SIPpTag091;did=07f.8fa>
Accept: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE

**response outgoing**
SIP/2.0 200 OK
From: sipp <sip:+9535346001@10.130.72.228>;tag=11368SIPpTag091
To: sut <sip:9535346001@10.130.72.228>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 INVITE
Content-Type: application/sdp
Content-Length:   162
Accept: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,UPDATE
Via: SIP/2.0/UDP 10.130.74.171:5060;rport=5060;branch=z9hG4bK-11368-1-7
Contact: <sip:atpsh-5fb50084-5b44-1@3.225.0.56>

**ACK Incoming**
ACK sip:atpsh-5fb50084-5b44-1@3.225.0.56 SIP/2.0
Via: SIP/2.0/UDP 10.130.74.171:5060;branch=z9hG4bK-11368-1-11
From: sipp <sip:sipp@10.130.74.171:5060>;tag=11368SIPpTag091
To: sut <sip:service@10.130.72.228:5060>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 ACK
Contact: sip:sipp@10.130.74.171:5060
Max-Forwards: 70
Subject: Performance Test
Content-Length: 0


**ACK outgoing**
ACK sip:atpsh-5fb3efba-4a95-1@52.55.224.188;alias=10.130.72.128~5060~1 SIP/2.0
Via: SIP/2.0/UDP 3.225.0.56:5060;branch=z9hG4bK4afa.773266b9ff87b7e02982aef7cafa13e7.0
From: sipp <sip:sipp@10.130.74.171:5060>;tag=11368SIPpTag091
To: sut <sip:service@10.130.72.228:5060>;tag=2
Call-ID: 1-11368@10.130.74.171
CSeq: 2 ACK
Max-Forwards: 69
Subject: Performance Test
Content-Length: 0
Route: <sip:10.130.74.130;lr;ftag=11368SIPpTag091;did=07f.8fa;nat=yes>
Contact: <sip:btpsh-5fb50084-5b44-1@3.225.0.56>






</code></pre>

<h3>Possible Solutions</h3>
<p>I checked code for topos_redis module, looks like only duiring initial transaction b_rr and a_rr values are stored<br>
<a href="https://github.com/kamailio/kamailio/blob/master/src/modules/topos_redis/topos_redis_storage.c#L1270">https://github.com/kamailio/kamailio/blob/master/src/modules/topos_redis/topos_redis_storage.c#L1270</a></p>

<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.2.8 (x86_64/linux) 5a7f5b
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 5a7f5b
compiled on 09:15:42 Nov 16 2020 with gcc 7.5.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>(paste your output here)
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2554">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZPTCYSNUZQDIJQZKD3SQO2CBANCNFSM4TZ4EHTQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZO7QMPZB4O53SLWWFLSQO2CBA5CNFSM4TZ4EHT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4LDQ7WVA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2554",
"url": "https://github.com/kamailio/kamailio/issues/2554",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>