<div dir="ltr"><div><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)">Well, 30 seconds seems to be the timeout of your SIP client: I suspect your client sends a 200OK but doesn&#39;t receive the ACK for it, and hence times out 30 seconds after and terminates the call. </span><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)">You can run ngrep to trace the call and see where the ACK is routed, and if it is routed to the correct address, if anything is not correct in its header. </span><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)">Personally, I run wireshark over an X11 tunnel for the GUI which helps a lot. If you provide ngrep trace, we may help you better.</span></div>

<div><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)"><br></span></div><div><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)">I had the exact same problem once, but don&#39;t remember what the reason was.. maybe incorrect loose routing section..</span></div>

<div><span style="font-family:tahoma,sans-serif;color:rgb(51,102,255)">Also try another client to make sure yours isn&#39;t broken..</span></div><div><div dir="ltr"><font color="#3366ff" face="tahoma, sans-serif"><br></font><div>

<font color="#3366ff" face="tahoma, sans-serif">Reda</font></div></div><br>
<br><br><div class="gmail_quote">On Mon, Apr 16, 2012 at 16:40, Karsten Horsmann <span dir="ltr">&lt;<a href="mailto:khorsmann@gmail.com">khorsmann@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Reda,<br>
<br>
<br>
my pitfall was that the probing takes 30seconds until the gateway is active<br>
until startup. So if i test it right after kamctl restart the gateway<br>
was inactive.<br>
<br>
Now i seems that my working multihomed config needs some help to fix<br>
nat for dispatching. For locatet user it works, for dispatching i run<br>
into nat-nightmare again<br>
(wrong Contact Header on private ip side and so one)....<br>
<br>
Any hints?<br>
<br>
<br>
# Main SIP request routing logic<br>
# - processing of any incoming SIP request starts with this route<br>
# - note: this is the same as route { ... }<br>
request_route {<br>
  xlog(&quot;begin routing\n&quot;);<br>
  setflag(1); # log this msg<br>
<br>
  #acc:<br>
  setflag(2);<br>
  setflag(3);<br>
  setflag(4);<br>
<br>
        # -----------------------------------------------------------------<br>
        # Sanity Check Section<br>
        # -----------------------------------------------------------------<br>
        # per request initial checks<br>
        route(REQINIT);<br>
<br>
        # -----------------------------------------------------------------<br>
        # Record Route Section<br>
        # -----------------------------------------------------------------<br>
        if (method!=&quot;REGISTER&quot;) {<br>
          record_route();<br>
        };<br>
<br>
        if (method==&quot;BYE&quot; || method==&quot;CANCEL&quot;) {<br>
                unforce_rtp_proxy();<br>
                xlog(&quot;L_DBG&quot;,&quot;BYE OR CANCEL. Dialog lifetime:<br>
$DLG_lifetime Status: $DLG_status\n&quot;);<br>
                if ($DLG_status==5)<br>
                {<br>
                        route(6);<br>
                }<br>
        }<br>
<br>
        # -----------------------------------------------------------------<br>
        # Loose Route Section<br>
        # -----------------------------------------------------------------<br>
        if (loose_route()) {<br>
                xlog(&quot;loose_route ***************\n&quot;);<br>
                if ((method==&quot;INVITE&quot; || method==&quot;REFER&quot;) &amp;&amp; !has_totag()) {<br>
                        sl_send_reply(&quot;403&quot;, &quot;Forbidden&quot;);<br>
                        return;<br>
                };<br>
<br>
                if (method==&quot;BYE&quot; &amp;&amp; $DLG_status==5)<br>
                {<br>
                        xlog(&quot;L_DBG&quot;,&quot;BYE. Dialog lifetime: $DLG_lifetime Status: $DLG_status\n&quot;);<br>
                        route(6);<br>
                }<br>
<br>
                if (method==&quot;INVITE&quot;) {<br>
                        route(5);<br>
<br>
                        if (!proxy_authorize(&quot;$td&quot;,&quot;subscriber&quot;)) {<br>
                           proxy_challenge(&quot;$td&quot;,&quot;0&quot;);<br>
                           return;<br>
                        } else if (!check_from()) {<br>
                           sl_send_reply(&quot;403&quot;, &quot;Use From=ID&quot;);<br>
                           return;<br>
                        };<br>
<br>
                        consume_credentials();<br>
                        setflag(6);<br>
                        force_rport();<br>
                        fix_nated_contact();<br>
<br>
                        if (dst_ip == 172.20.100.74){<br>
                            rtpproxy_manage(&quot;fiewc&quot;,&quot;212.59.42.189&quot;);<br>
                        }<br>
                        else<br>
                        {<br>
                            rtpproxy_manage(&quot;feiwc&quot;,&quot;172.20.100.74&quot;);<br>
                        }<br>
              };<br>
          route(1);<br>
          return;<br>
        };<br>
<br>
<br>
        if (method==&quot;CANCEL&quot;)<br>
        {<br>
                xlog(&quot;L_DBG&quot;,&quot;CANCEL. Dialog lifetime: $DLG_lifetime<br>
Status: $DLG_status\n&quot;);<br>
                route(6);<br>
        }<br>
<br>
        # -----------------------------------------------------------------<br>
        # Call Type Processing Section<br>
        # -----------------------------------------------------------------<br>
        xlog(&quot;call type processing\n&quot;);<br>
        if (uri!=myself) {<br>
                route(4);<br>
                route(1);<br>
                return;<br>
        };<br>
<br>
        if (method==&quot;ACK&quot;) {<br>
                route(1);<br>
                return;<br>
        } else if (method==&quot;CANCEL&quot;) {<br>
                route(1);<br>
                return;<br>
        } else if (method==&quot;INVITE&quot;) {<br>
                route(5);<br>
                route(3);<br>
                return;<br>
        } else  if (method==&quot;REGISTER&quot;) {<br>
                route(2);<br>
                return;<br>
        };<br>
<br>
        xlog(&quot;lookup aliases\n&quot;);<br>
        lookup(&quot;aliases&quot;);<br>
        if (uri!=myself) {<br>
                route(4);<br>
                route(1);<br>
                return;<br>
        };<br>
<br>
        xlog(&quot;!lookup location\n&quot;);<br>
        if (!lookup(&quot;location&quot;)) {<br>
                sl_send_reply(&quot;404&quot;, &quot;User Not Found&quot;);<br>
                return;<br>
        };<br>
<br>
        route(1);<br>
<br>
}<br>
<br>
route[1] {<br>
<br>
        # -----------------------------------------------------------------<br>
        # Default Message Handler<br>
        # -----------------------------------------------------------------<br>
<br>
        t_on_reply(&quot;1&quot;);<br>
<br>
        if (!t_relay()) {<br>
                if (method==&quot;INVITE&quot; &amp;&amp; isflagset(6)) {<br>
                        unforce_rtp_proxy();<br>
                };<br>
                sl_reply_error();<br>
        };<br>
}<br>
<br>
route[2] {<br>
<br>
        # -----------------------------------------------------------------<br>
        # REGISTER Message Handler<br>
        # ----------------------------------------------------------------<br>
<br>
        setflag(6);<br>
        fix_nated_register();<br>
        force_rport();<br>
<br>
        sl_send_reply(&quot;100&quot;, &quot;Trying&quot;);<br>
<br>
        if (!www_authorize(&quot;$td&quot;,&quot;subscriber&quot;)) {<br>
          www_challenge(&quot;$td&quot;,&quot;0&quot;);<br>
          return;<br>
        };<br>
<br>
        if (!check_to()) {<br>
          sl_send_reply(&quot;401&quot;, &quot;Unauthorized&quot;);<br>
          return;<br>
        };<br>
<br>
        consume_credentials();<br>
<br>
        if (!save(&quot;location&quot;)) {<br>
           log(1,&quot;Error :-(.\n&quot;);<br>
           sl_reply_error();<br>
        };<br>
}<br>
<br>
route[3] {<br>
<br>
        # -----------------------------------------------------------------<br>
        # INVITE Message Handler<br>
        # -----------------------------------------------------------------<br>
        xlog(&quot;route-3\n&quot;);<br>
        setflag(6);<br>
<br>
        lookup(&quot;aliases&quot;);<br>
        if (uri!=myself) {<br>
                route(4);<br>
                route(1);<br>
                return;<br>
<div class="im">        };<br>
<br>
<br>
#!ifdef WITH_DISPATCHER<br>
        if (!lookup(&quot;location&quot;)) {<br>
                if(ds_select_domain(&quot;1&quot;, &quot;4&quot;)) {<br>
                xlog(&quot;DISPATCHER ds_select_dst\n&quot;);<br>
</div>                route(4);<br>
                #route(1);<br>
                forward();<br>
                return;<br>
                }<br>
        }<br>
#!endif<br>
<br>
        if (!lookup(&quot;location&quot;)) {<br>
                xlog(&quot;404 User not found\n&quot;);<br>
                sl_send_reply(&quot;404&quot;, &quot;User Not Found&quot;);<br>
                return;<br>
        };<br>
<br>
        route(4);<br>
        route(1);<br>
}<br>
<br>
route[4] {<br>
<br>
        # -----------------------------------------------------------------<br>
        # NAT Traversal Section<br>
        # -----------------------------------------------------------------<br>
<br>
        force_rport();<br>
        fix_nated_contact();<br>
        if (dst_ip == 172.20.100.74){<br>
            xlog(&quot;INVITE 4  intern extern\n&quot;);<br>
            rtpproxy_manage(&quot;fiewc&quot;,&quot;222.222.222.222&quot;);<br>
        }<br>
        else<br>
        {<br>
            xlog(&quot;INVITE 4 extern intern\n&quot;);<br>
            rtpproxy_manage(&quot;feiwc&quot;,&quot;172.20.100.74&quot;);<br>
        }<br>
}<br>
<br>
route[5] {<br>
<br>
        # ----------------------------------------------------------------<br>
        # Save here CDR Variables<br>
        # ----------------------------------------------------------------<br>
<br>
        #save sourceIP<br>
        $sht(a=&gt;$ci::srcip) = $si;<br>
        $sht(a=&gt;$ci::fromdplname) = $fn;<br>
        $sht(a=&gt;$ci::touri) = $tu;<br>
        $sht(a=&gt;$ci::fromuri) = $fu;<br>
        $sht(a=&gt;$ci::useragent) = $ua;<br>
}<br>
<br>
route[6] {<br>
<br>
        # ----------------------------------------------------------------<br>
        # Write CDR via Perl and free previously CDR Variables<br>
        # ----------------------------------------------------------------<br>
<br>
        #save variables from htable in AVPs, so we can access them from perl<br>
(without memory leak)<br>
        $avp(s:4com_srcip)=$sht(a=&gt;$ci::srcip);<br>
        $avp(s:4com_fromdplname)=$sht(a=&gt;$ci::fromdplname);<br>
        $avp(s:4com_touri)=$sht(a=&gt;$ci::touri);<br>
        $avp(s:4com_fromuri)=$sht(a=&gt;$ci::fromuri);<br>
        $avp(s:4com_useragent)=$sht(a=&gt;$ci::useragent);<br>
        $avp(s:4com_invtrytime)=$sht(a=&gt;$ci::invtrytime);<br>
<br>
        #write CDR<br>
        perl_exec(&quot;write_cdr&quot;);<br>
<br>
        #free all variables saved in hashtable<br>
        sht_rm_name_re(&quot;a=&gt;$ci::.*&quot;);<br>
<br>
}<br>
<br>
<br>
onreply_route[1] {<br>
<br>
        rtpproxy_manage(&quot;fwc&quot;);<br>
        fix_nated_contact();<br>
<br>
        #if (is_gflag(&quot;0&quot;)) log(1,&quot;-- 0 ist gesetzt.\n&quot;);<br>
        #if (is_gflag(&quot;1&quot;)) log(1,&quot;-- 1 ist gesetzt.\n&quot;);<br>
        #if (is_gflag(&quot;2&quot;)) log(1,&quot;-- 2 ist gesetzt.\n&quot;);<br>
        #if (is_gflag(&quot;3&quot;)) log(1,&quot;-- 3 ist gesetzt.\n&quot;);<br>
<br>
        #if (is_gflag(&quot;1&quot;))<br>
        #{<br>
        #  log(1,&quot;Recording this Call\n&quot;);<br>
        #  start_recording();<br>
        #}<br>
        #else<br>
        #{<br>
        #  log(1,&quot;NOT recording this Call\n&quot;);<br>
        #}<br>
<br>
        xlog(&quot;L_DBG&quot;, &quot;-- Status: $rs  METHOD $rm Reason $rr\n&quot;);<br>
        if ($rm==&quot;INVITE&quot;)<br>
        {<br>
                xlog(&quot;L_DBG&quot;, &quot;Method is INVITE\n&quot;);<br>
                if ($rs=~&quot;1[0-9][0-9]&quot;)<br>
                {<br>
                        xlog(&quot;L_DBG&quot;, &quot;Status is in 100-class Trying\n&quot;);<br>
                        $sht(a=&gt;$ci::invtrytime) = $Ts;<br>
                        #perl_exec(&quot;got_invite_trying&quot;);<br>
                }<br>
                else if ($rs=~&quot;4[0-9][0-9]&quot;)<br>
                {<br>
                        xlog(&quot;L_DBG&quot;, &quot;Status is in 400-class - ClientErrors\n&quot;);<br>
                        #xlog(&quot;L_DBG&quot;, &quot;SI aus shared: $sht(a=&gt;$ci::srcip)\n&quot;);<br>
                        #perl_exec(&quot;write_cdr&quot;);<br>
                        #sht_rm_name_re(&quot;a=&gt;$ci::.*&quot;);<br>
                        route(6);<br>
                }<br>
        }<br>
}<br>
<br>
####<br>
# Per SIP request initial checks<br>
route[REQINIT] {<br>
#!ifdef WITH_ANTIFLOOD<br>
        # flood dection from same IP and traffic ban for a while<br>
        # be sure you exclude checking trusted peers, such as pstn gateways<br>
        # - local host excluded (e.g., loop to self)<br>
        if(src_ip!=myself)<br>
        {<br>
                if($sht(ipban=&gt;$si)!=$null)<br>
                {<br>
                        # ip is already blocked<br>
                        xdbg(&quot;request from blocked IP - $rm from $fu (IP:$si:$sp)\n&quot;);<br>
                        exit;<br>
                }<br>
                if (!pike_check_req())<br>
                {<br>
                        xlog(&quot;L_ALERT&quot;,&quot;ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n&quot;);<br>
                        $sht(ipban=&gt;$si) = 1;<br>
                        exit;<br>
                }<br>
        }<br>
#!endif<br>
<br>
        if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>
                sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>
                exit;<br>
        }<br>
<br>
        if(!sanity_check(&quot;1511&quot;, &quot;7&quot;))<br>
        {<br>
                xlog(&quot;Malformed SIP message from $si:$sp\n&quot;);<br>
                exit;<br>
<div class="HOEnZb"><div class="h5">        }<br>
}<br>
<br>
--<br>
Mit freundlichen Grüßen<br>
*Karsten Horsmann*<br>
<br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div></div></blockquote></div><br></div></div>