<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I’ve done some digging and realised that outbound calls I initiate Asterisk -> Kamailio -> Trunk are receiving the BYE correctly. However the previously provided flow was Drachtio -> Kamailio -> Trunk.<br class=""><div class="">
<div dir="auto" style="text-align: start; text-indent: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; text-align: start; text-indent: 0px;"><br class="">I suspect the dialog is not being initialised correctly in some way from Drachtio. I can make changes as required here, but I need help spotting the difference between the two.</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; text-align: start; text-indent: 0px;"><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; text-align: start; text-indent: 0px;">I ran a kamcmd dlg.list on a test call Asterisk -> Kamailio -> Trunk, and another one on Drachtio -> Kamailio -> Trunk, here are the results (with IPs anonymised and replaced with pseudo hostnames):</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; text-align: start; text-indent: 0px;"><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none; -webkit-text-stroke-width: 0px; font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; text-align: start; text-indent: 0px;">Asterisk -> Kamailio -> Trunk:</div><div style="text-align: start; text-indent: 0px;"><a href="https://pastebin.com/WkFefUGB" class="">https://pastebin.com/WkFefUGB</a></div><div style="text-align: start; text-indent: 0px;"><br class=""></div><div style="text-align: start; text-indent: 0px;">Drachtio -> Kamailio -> Trunk:</div><div style="text-align: start; text-indent: 0px;"><a href="https://pastebin.com/aX5hdqUE" class="">https://pastebin.com/G3bzNYY0</a></div><div style="text-align: start; text-indent: 0px;"><br class=""></div><div style="text-align: start; text-indent: 0px;">I don’t know the inner workings of Kamailio dialogs well, but these look very similar to me. Am I on the right track here, is there other debug information I can dump to compare what’s happening and why this BYE its going to the wrong end?</div><div style="text-align: start; text-indent: 0px;"><br class=""></div><div style="text-align: start; text-indent: 0px;">Thanks,</div><div style="text-align: start; text-indent: 0px;"><br class=""></div><div style="text-align: start; text-indent: 0px;">Andrew</div></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 23 Jun 2019, at 5:39 pm, Andrew White <<a href="mailto:andrew@uconnected.com.au" class="">andrew@uconnected.com.au</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi team!<div class=""><br class=""></div><div class="">I’ve recently found an issue in my Kamailio setup. It appears when the trunk replies to call in progress with a BYE, we relay it immediately back to them:</div><div class=""><br class=""></div><div class=""><a href="https://i.imgur.com/h5fusau.png" class="">https://i.imgur.com/h5fusau.png</a></div><div class=""><br class=""></div><div class="">The only differences in the second BYE is the Route header is removed and replaced with a Via header referencing the Kamailio machine, and the From URI is rewritten to show the Kamailio hostname.<br class="">
<br class=""></div><div class=""><br class=""></div><div class="">I’m unsure what steps I can take here, as all of my out of dialog messages (180, 200, ACK) are forwarded along with no issue. It seems only the in dialog are having this issue.</div><div class=""><br class=""></div><div class="">Here’s my WITHINDLG and RELAY:</div><div class=""><br class=""></div><div class=""><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;" class=""><div class="">  <span style="color: #c586c0;" class="">def</span> <span style="color: #dcdcaa;" class="">ksr_route_relay</span>()</div><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_method_in(<span style="color: #ce9178;" class="">"IBSU"</span>) <span style="color: #c586c0;" class="">then</span></div><div class="">      <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_is_set(<span style="color: #ce9178;" class="">"branch_route"</span>) < <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">        <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_on_branch(<span style="color: #ce9178;" class="">"ksr_branch_manage"</span>)</div><div class="">      <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_method_in(<span style="color: #ce9178;" class="">"ISU"</span>) <span style="color: #c586c0;" class="">then</span></div><div class="">      <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_is_set(<span style="color: #ce9178;" class="">"onreply_route"</span>) < <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">        <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_on_reply(<span style="color: #ce9178;" class="">"ksr_onreply_manage"</span>)</div><div class="">      <span style="color: #c586c0;" class="">end</span></div><div class="">      <span style="color: #6a9955;" class="">#<a href="http://ksr.info/" class="">KSR.info</a>("Onreply route: #{KSR::TM.t_is_set("onreply_route")}")</span></div><div class="">    <span style="color: #c586c0;" class="">end</span> </div><div class="">  </div><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_INVITE() <span style="color: #c586c0;" class="">then</span></div><div class="">      <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_is_set(<span style="color: #ce9178;" class="">"failure_route"</span>) < <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">        <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_on_failure(<span style="color: #ce9178;" class="">"ksr_failure_manage"</span>)</div><div class="">      <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #c586c0;" class="">end</span></div><div class="">  </div><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_relay() < <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">      <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">SL</span>.sl_reply_error()</div><div class="">    <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #dcdcaa;" class="">exit</span></div><div class="">  <span style="color: #c586c0;" class="">end</span></div><br class=""><div class="">  <span style="color: #c586c0;" class="">def</span> <span style="color: #dcdcaa;" class="">ksr_route_withindlg</span>()</div><div class="">    <span style="color: #c586c0;" class="">return</span> <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">SIPUTILS</span>.has_totag() < <span style="color: #b5cea8;" class="">0</span></div><br class=""><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">RR</span>.loose_route() > <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">      ksr_route_dlguri()</div><div class="">      <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_BYE() <span style="color: #c586c0;" class="">then</span></div><div class="">        <span style="color: #6a9955;" class="">#KSR.setflag($myenv['FLT_ACC'].to_i)</span></div><div class="">        <span style="color: #6a9955;" class="">#KSR.setflag($myenv['FLT_ACCFAILED'].to_i)</span></div><div class="">      <span style="color: #c586c0;" class="">elsif</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_ACK() <span style="color: #c586c0;" class="">then</span></div><div class="">        ksr_route_natmanage()</div><div class="">      <span style="color: #c586c0;" class="">elsif</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_NOTIFY() <span style="color: #c586c0;" class="">then</span></div><div class="">        <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">RR</span>.record_route()</div><div class="">      <span style="color: #c586c0;" class="">end</span></div><div class="">      ksr_route_relay()</div><div class="">      <span style="color: #dcdcaa;" class="">exit</span></div><div class="">    <span style="color: #c586c0;" class="">end</span></div><br class=""><div class="">    <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>.is_ACK() <span style="color: #c586c0;" class="">then</span></div><div class="">      <span style="color: #6a9955;" class="">#<a href="http://ksr.info/" class="">KSR.info</a>("Handling an ACK within dialog")</span></div><div class="">      <span style="color: #c586c0;" class="">if</span> <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">TM</span>.t_check_trans() > <span style="color: #b5cea8;" class="">0</span> <span style="color: #c586c0;" class="">then</span></div><div class="">        ksr_route_relay()</div><div class="">        <span style="color: #dcdcaa;" class="">exit</span></div><div class="">      <span style="color: #c586c0;" class="">else</span></div><div class="">        <span style="color: #dcdcaa;" class="">exit</span></div><div class="">      <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #c586c0;" class="">end</span></div><div class="">    <span style="color: #6a9955;" class="">#<a href="http://ksr.info/" class="">KSR.info</a>("404ing within dialog")</span></div><div class="">    <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">SL</span>.sl_send_reply(<span style="color: #b5cea8;" class="">404</span>, <span style="color: #ce9178;" class="">"Not here"</span>);</div><div class="">    <span style="color: #dcdcaa;" class="">exit</span></div><div class=""><span style="color: #c586c0;" class="">end</span></div></div></div><div class=""><br class=""></div><div class="">I suspect I must be sending this to the wrong branch somehow, but I’m unsure how to correct this. The call gets originally initiated from Kamailio writing a custom RURI and To header before calling t_relay(). I’m wondering if I’m somehow initiating the dialog incorrectly and as such the BYE doesn’t know where to go.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Andrew</div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></div></body></html>