<h3>Description</h3>
<p>The R-URI is not un-masked/update by Kamailio topos module if the BYE message is received later than in 3 minutes after dialog begin.</p>
<p>We are using 5.1.4 plus the patch for 302 message on top, but tried also with topos/topos_redis from master, same result.</p>
<h3>Troubleshooting</h3>
<p>for keys like [d:z:atpsh-5b619dee-5ca4-441] topos is using branch timeout value, default being 3 minutes, so if a BYE message arrives later than branch timeout expiry the records are deleted and the R-URI is not updated. The new header being Route and P-SR-XUID are still added as I can see from the debug log, but BYE relayed by kamailio contains improper R-URI user atpsh-5b619dee-5ca4-441.</p>
<p>I've tested this using automated shorter calls because we don't need to wait 3 minutes to notice that TTL is being set improperly.  When checking the debug I noticed that tps_redis_end_dialog() is called here, despite the BYE was not received yet:</p>
<p>Aug  1 14:59:03 sp1 lb[23716]: DEBUG: topos [tps_msg.c:182]: tps_add_headers(): adding to headers(1) - [Via: SIP/2.0/UDP 127.0.0.1;branch=z9hG4bK4c5e.5b0c6948caefcd8ffb1d106989768f80.0#015#012]<br>
Aug  1 14:59:03 sp1 lb[23716]: DEBUG: topos [tps_msg.c:182]: tps_add_headers(): adding to headers(0) - [Contact: sip:btpsh-5b619dee-5ca4-441@127.0.0.1<a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="52852064" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/15" href="https://github.com/kamailio/kamailio/issues/15">#15</a>#012]<br>
Aug  1 14:59:03 sp1 lb[23716]: DEBUG: topos_redis [topos_redis_storage.c:1381]: tps_redis_end_dialog(): updated on end the dialog record for [d:z:atpsh-5b619dee-5ca4-441] with argc 6<br>
Aug  1 14:59:03 sp1 lb[23716]: DEBUG: topos_redis [topos_redis_storage.c:1412]: tps_redis_end_dialog(): expire set on branch record for [d:z:atpsh-5b619dee-5ca4-441] with argc 3</p>
<p>This matches the EXPIRES command time in the output of redis-cli monitor:</p>
<p>1533128343.178930 [24 127.0.0.1:48634] "HGETALL" "d:z:atpsh-5b619dee-5ca4-441"<br>
1533128343.180122 [24 127.0.0.1:48634] "HMSET" "d:z:atpsh-5b619dee-5ca4-441" "rectime" "1533128343" "iflags" "0"<br>
1533128343.180565 [24 127.0.0.1:48634] "EXPIRE" "d:z:atpsh-5b619dee-5ca4-441" "180"</p>
<p>Is it expected that tps_redis_end_dialog is called at all, changing the expiry and iflag?</p>
<h4>Reproduction</h4>
<p>Make a call with topos, ndb_redis and topos_redis modules loaded.<br>
In our case, the call traverses the kamailio-lb instance twice, because there is a sems in between.</p>
<h4>Debugging Data, log messages, traces</h4>
<p>will be provided as an attachment<br>
<a href="https://github.com/kamailio/kamailio/files/2249809/dumps.tar.gz">dumps.tar.gz</a></p>
<h3>Additional Information</h3>
<p>version: kamailio 5.1.4 (x86_64/linux)<br>
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, 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<br>
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.<br>
id: unknown<br>
compiled with gcc 6.3.0</p>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>
<p>Linux sp1 4.9.0-6-amd64 <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="31891578" data-permission-text="Issue title is private" data-url="https://github.com/kamailio/kamailio/issues/1" href="https://github.com/kamailio/kamailio/issues/1">#1</a> SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux</p>

<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/1608">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZV7osyDdD7tMqDiK9b4OmDYqVKmoks5uMboWgaJpZM4VqmV9">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZdZQTU73-jmyLMghSSrBglvLiOqmks5uMboWgaJpZM4VqmV9.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"topos/topos_redis is using wrong dialog end timeout (#1608)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1608"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1608",
"url": "https://github.com/kamailio/kamailio/issues/1608",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "topos/topos_redis is using wrong dialog end timeout (#1608)",
"sections": [
{
"text": "",
"activityTitle": "**Andrew Pogrebennyk**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@apogrebennyk",
"facts": [
{
"name": "Repository: ",
"value": "kamailio/kamailio"
},
{
"name": "Issue #: ",
"value": 1608
}
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1608,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1608\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1608"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 363488637\n}"
}
],
"themeColor": "26292E"
}
]</script>