<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class=""><br class=""></div><div class="">I’ve got a call flow where PBX makes a call via Kamailio, which uses the UAC modules to make the call to the trunk. This works great, however I’ve noticed recently that when the BYE comes from the trunk, Kamailio doesn’t recognise the dialog and throws back a 404. Due to this, the PBX never knows the session has ended, and keeps its session open.</div><div class=""><br class=""></div><div class="">Here’s the flow from Wireshark:</div><div class=""><br class=""></div><div class=""><a href="https://i.imgur.com/BxPRrXP.png" class="">https://i.imgur.com/BxPRrXP.png</a></div><div class=""><br class=""></div><div class="">As you can see, the BYE is received from the trunk, and Kamailio throws a 404. I checked with an rpc dlg.list and at this point the dialog had gone. 30 seconds later, I threw a BYE from the PBX, and because the dialog no longer existed, it got a 481 back.</div><div class=""><br class=""></div><div class="">The INVITE to the trunk has the following Record-Route header:</div><div class=""><br class=""></div><div class=""><font face="Courier New" size="1" class="">Record-Route: <<a href="sip:kamailio.public-ip;lr;ftag=mjKtcKaBteQ4Q;vst=AAAAAAYFBQUHAwYHBgRzMwIRGRMcAgJBWBEVCwAbBhtADxBjdGVkLmNvbS5hdQ--;did=624.b2e1" class="">sip:kamailio.public-ip;lr;ftag=mjKtcKaBteQ4Q;vst=AAAAAAYFBQUHAwYHBgRzMwIRGRMcAgJBWBEVCwAbBhtADxBjdGVkLmNvbS5hdQ--;did=624.b2e1</a>></font></div><div class=""><br class=""></div><div class="">When the first BYE comes in, it still has same did in the Route header.</div><div class=""><br class=""></div><div class="">Below I’ve put the output from the dialog list rpc call (before the first BYE) and the relevant log lines. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">{</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        h_entry: 1062</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        h_id: 7723</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        ref: 2</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        call-id: a9d32620-2b68-1238-048a-0cc47a18705a</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        from_uri: <a href="sip:61400123123@pbx.local:5060" class="">sip:61400123123@pbx.local:5060</a></font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        to_uri: <a href="sip:61400123123@10.0.0.2" class="">sip:61400123123@10.0.0.2</a></font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        state: 4</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        start_ts: 1564269942</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        init_ts: 1564269929</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        end_ts: 0</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        timeout: 1564313142</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        lifetime: 43200</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        dflags: 643</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        sflags: 0</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        iflags: 16</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        caller: {</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                tag: mjKtcKaBteQ4Q</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                contact: <a href="sip:pbx.local" class="">sip:pbx.local</a></font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                cseq: 7581172</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                route_set:</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                socket: udp:</font></span><span style="font-family: "Courier New"; font-size: x-small;" class="">10.0.0.2</span><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">:5060</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        }</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        callee: {</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                tag: SD5ptp899-1177933201-1564269931305</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                contact: <a href="sip:SDd3mt8-nn9jnirnmqcrvfmvkpm0hmhvgggjgv2io788of70s84u9@trunk.remote:5060;transport=udp" class="">sip:SDd3mt8-nn9jnirnmqcrvfmvkpm0hmhvgggjgv2io788of70s84u9@trunk.remote:5060;transport=udp</a></font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                cseq: 0</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                route_set:</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                socket: udp:</font></span><span style="font-family: "Courier New"; font-size: x-small;" class="">10.0.0.2</span><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">:5060</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        }</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        profiles: {</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        }</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        variables: {</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                {</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                        cseq_diff: 1</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">                }</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">        }</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class="">}</font></span></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class=""><br class=""></font></span></div><div class=""><font face="Courier New" size="1" class="">Jul 28 09:27:30 ip-10-0-0-2 /usr/local/sbin/kamailio[11061]: NOTICE: {2 450917085 BYE a9d32620-2b68-1238-048a-0cc47a18705a} acc [acc.c:279]: acc_log_request(): ACC: transaction answered: timestamp=1564270050;method=BYE;from_tag=SD5ptp899-1177933201-1564269931305;to_tag=mjKtcKaBteQ4Q;call_id=a9d32620-2b68-1238-048a-0cc47a18705a;code=404;reason=Not here;src_user=0400123123;src_domain=trunk.remote;src_ip=trunk.remote;dst_ouser=0400123123;dst_user=0400123123;dst_domain=kamailio.public-ip</font></div></div><div class=""><span style="font-style: normal;" class=""><font face="Courier New" size="1" class=""><br class=""></font></span></div><div class="">I’m assuming the 404 is because the Contact header I sent from Kamailio -> Trunk is rewritten, that Contact is Kamailio’s public contact IP. However the dialog has the caller contact within it referencing back to the local PBX, so I would think when Kamailio gets this dialog ID back with a BYE it would relay it back to the original contact, wouldn’t it?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Andrew</div></body></html>