<div dir="ltr">I corrected an error with my dispatcher configuration and now, I do hit the code where <div><br></div><div>ds_select_dst ("1", "4")</div><div><br></div><div>is no longer null.</div><div><br></div><div>However, while the xlog I added says uac_req_send () is called, nothing is sent. The xlog prints out the value of $uac_req(hdrs) as</div><div><br></div><div> Contact: <<a href="http://sip:101@192.168.1.101:5060">sip:101@192.168.1.101:5060</a>>#015#012Expires: 600#015<br></div><div><br></div><div>after which the uac_req_send () is called.</div><div><br></div><div>I am not sure if this is the correct way? What am I missing?</div><div><br></div><div>Oh, nothing shows up in the tcpdump trace (only the OPTIONS message for the asterisk<->kamailio peering shows up).</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 23, 2016 at 3:48 PM, Tickling Contest <span dir="ltr"><<a href="mailto:tickling.contest@gmail.com" target="_blank">tickling.contest@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks, guys!<br><div><br></div><div>Sammy, I tried your code in REGFWD, but unfortunately, it does not forward anything to Asterisk. I can confirm this because it keeps going into the else clause in the REGFWD (which I added to confirm). My current REGFWD looks like this:</div><div><br></div><div><span class=""><div>route[REGFWD] {</div><div>        if(!is_method("REGISTER"))</div><div>        {</div><div>                return;</div><div>        }</div></span><div>        xlog ("L_DEBUG", "MYDEBUG: In REGFWD");</div><span class=""><div>        if(!ds_select_dst("1", "4"))    {</div><div>               $var(rip) = $(du{s.select,1,:});</div><div>               $var(rport) = $(du{s.select,2,:});</div><div>               $uac_req(method)="REGISTER";</div><div>               $uac_req(ruri)="sip:" + $var(rip) + ":" + $var(rport) + ";transport=tcp";</div><div>               $uac_req(furi)="sip:" + $au + "@" + $var(rip);</div><div>               $uac_req(turi)="sip:" + $au + "@" + $var(rip);</div></span><div>               $uac_req(hdrs)="Contact: <sip:" + $au + "@<a href="http://192.168.1.101:5060" target="_blank">192.168.1.101:5060</a>" + ">\r\n";</div><div>                xlog ("L_DEBUG", "MYDEBUG: In REGFWD, sending registration info to Asterisk at $uac_req(ruri)");</div><span class=""><div>               if($sel(contact.expires) != $null)</div><div>                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";</div><div>                else</div><div>                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";</div><div>                uac_req_send();</div><div>        }</div></span><div>        else</div><div>        {</div><div>                xlog ("L_DEBUG", "In REGFWD, not forwarding!");</div><div>        }</div><div><br></div><div>}</div></div><div><br></div><div><br></div><div><br></div><div>My entire kamailio.cfg file is here: <a href="https://gist.github.com/ticklingcontest/f96aa4d08b08dc4643056d73da24f0a5" target="_blank">https://gist.github.com/ticklingcontest/f96aa4d08b08dc4643056d73da24f0a5</a></div><div><br></div><div>Any insight is appreciated. Thanks again.</div><div><br></div><div>My dispatcher at the moment has only one Asterisk server. My endpoint registers (auth with realtime DB in Mysql), but the registration information does not reach Asterisk.</div><div><br></div><div>My kamailio box is peering with the asterisk box like so:</div><div><br></div><div><div>root@asterisk:~# more /etc/asterisk/pjsip_wizard.conf</div><div>[kamailio]</div><div>type = wizard</div><div>sends_auth = no</div><div>sends_registrations = no</div><div>remote_hosts = 192.168.1.101</div><div>server_uri_pattern = sip:${REMOTE_HOST}\;transport=tcp</div><div>client_uri_pattern = sip:${REMOTE_HOST}\;transport=tcp</div><div>contact_pattern = sip:${REMOTE_HOST}\;transport=tcp</div><div>outbound_auth/username = dispatcher</div><div>aor/qualify_frequency = 0</div><div>endpoint/context = from-external ;;; change later</div><div>endpoint/disallow = all ;;; change later</div><div>endpoint/allow = ulaw ;;; change later</div><div>endpoint/dtmf_mode=rfc4733</div><div>endpoint/media_address=192.168.1.101 ;;</div><div>aor/qualify_frequency = 15</div></div><div><br></div><div>BTW, my intention is to store the registrations on the Asterisk servers as well as my ARI code depends on it. As soon I get the single Asterisk situation working, I intend adding more servers to check the load balancing and REGISTER forwarding, and to Colin's point, the business of just using Kamailio as an outbound proxy.</div><div><br></div><div>Again, any insight wrt why no REGISTERs are forwarding to Asterisk is appreciated. Why is ds_select_dst("1", "4") evaluating to false for me?</div><div><br></div><div>My dispatcher info:</div><div><br></div><div><div>root@kamailio:/etc/kamailio# kamctl dispatcher show</div><div>dispatcher gateways</div><div>+----+-------+-------------------+-------+----------+-------+-------------+</div><div>| id | setid | destination       | flags | priority | attrs | description |</div><div>+----+-------+-------------------+-------+----------+-------+-------------+</div><div>|  1 |     1 | sip:192.168.1.102 |     1 |        0 |       | AsteriskA   |</div><div>|  2 |     1 | sip:192.168.1.102 |     1 |        0 |       | AsteriskA   |</div><div>+----+-------+-------------------+-------+----------+-------+-------------+</div></div><div><br></div><div><br></div><div>Thanks!</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 22, 2016 at 11:01 AM, Colin Morelli <span dir="ltr"><<a href="mailto:colin.morelli@gmail.com" target="_blank">colin.morelli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you're using Kamailio as a registrar, then it would make the most sense to also use it as your outbound proxy for Asterisk.<br><br>This would mean whenever Asterisk needs to dial an extension, it would instead make a SIP call to your Kamailio instance which would then perform the lookup, forking, and forwarding.<br><br>Is there a reason this wouldn't work in your infrastructure? If for some reason it can't - though I can't imagine how - then I don't see the purpose in using Kamailio as a registrar at all. You should just forward everything to Asterisk since it needs to be there anyway.<br><br>Best,<br>Colin<div><div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 22, 2016 at 9:58 AM SamyGo <<a href="mailto:govoiper@gmail.com" target="_blank">govoiper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Tickles,<div><br></div><div>a) Have you tried doing this on Asterisk realtime ? for any regular direct registering extension w/o kamailio(even before kamailio) ? If an extension registers to one asterisk the rest of the boxes would know where to contact this extension via realtime-db ? I'd say give that a try and it may solve your problem, else using this REGFWD block you can parallel fork this register request to ALL of your boxes and everybox would think it is registered locally ! (not a recommended option I must say)</div><div><br>b) If you ignore my previous comment of parallel forking registers, using this  REGFWD block you can use dispatcher module to replace the $var(rip) and <span style="font-size:12.8px">$sel(cfg_get.asterisk.</span><span style="font-size:12.8px">bindport) by changing your REGFWD block like this:<br><br></span></div></div><div dir="ltr"><div><div style="font-size:12.8px"><font face="monospace, monospace">route[REGFWD] {</font></div><div style="font-size:12.8px"><font face="monospace, monospace">        if(!is_method("REGISTER"))</font></div><div style="font-size:12.8px"><font face="monospace, monospace">        {</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                return;</font></div><div style="font-size:12.8px"><font face="monospace, monospace">        }</font></div></div></div><div dir="ltr"><div><div style="font-size:12.8px"><font face="monospace, monospace">       <span style="background-color:rgb(255,229,153)"> if(!ds_select_dst("1", "4"))    { </span></font></div><div style="font-size:12.8px"><font face="monospace, monospace">               <span style="background-color:rgb(255,229,153)">$var(rip) = $(du{s.select,1,:});</span><br>               <span style="background-color:rgb(255,229,153)">$var(rport) = </span><span style="font-size:12.8px"><span style="background-color:rgb(255,229,153)">$(du{s.select,2,:});</span><br></span></font></div><div style="font-size:12.8px"><font face="monospace, monospace">               $uac_req(method)="REGISTER";</font></div><div style="font-size:12.8px"><font face="monospace, monospace">               $uac_req(ruri)="sip:" + $var(rip) + ":" + $var(rport) + ";transport=tcp";</font></div></div></div><div dir="ltr"><div><div style="font-size:12.8px"><font face="monospace, monospace">               $uac_req(furi)="sip:" + $au + "@" + $var(rip);</font></div><div style="font-size:12.8px"><font face="monospace, monospace">               $uac_req(turi)="sip:" + $au + "@" + $var(rip);</font></div><div style="font-size:12.8px"><font face="monospace, monospace">               $uac_req(hdrs)="Contact: <sip:" + $au + "@"</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                                + $sel(cfg_get.kamailio.bindip)</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                                + ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";</font></div><div style="font-size:12.8px"><font face="monospace, monospace">               if($sel(contact.expires) != $null)</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                else</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";</font></div><div style="font-size:12.8px"><font face="monospace, monospace">                uac_req_send();</font></div><div style="font-size:12.8px"><font face="monospace, monospace">        <span style="background-color:rgb(255,229,153)">}</span></font></div></div></div><div dir="ltr"><div></div><div style="font-size:12.8px"><font face="monospace, monospace"><br></font></div><div style="font-size:12.8px"><font face="monospace, monospace">}</font></div><div><br></div><div><br>In summary, depending upon your business logic/use case there could be other ways to make this work as well.<br><br></div><div>Regards,</div><div>Sammy</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 22, 2016 at 8:53 AM, Tickling Contest <span dir="ltr"><<a href="mailto:tickling.contest@gmail.com" target="_blank">tickling.contest@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>When using Kamailio with the dispatcher module for Asterisk load balancing, I am offloading REGISTERs to Kamailio (works fine), but would like to forward the REGISTERs to Asterisk so that outgoing calls from Asterisk will be possible. I know this is not strictly necessary (e.g., just use Kamailio to forward everything), but I have a lot of application logic behind my Asterisk boxes (using ARI) and so I don't want that to break. Thereby, I do need this information in Asterisk as soon as possible from Kamailio.</div><div><br></div><div>Let's say I have three boxes Asterisk_1, Asterisk_2 and Asterisk_3 in the dispatcher module like so:</div><div><div><br></div><div>1 sip:192.168.1.201:5060;transport=tcp</div></div><div><div>1 sip:192.168.1.202:5060;transport=tcp</div></div><div><div>1 sip:192.168.1.203:5060;transport=tcp</div></div><div><br></div><div>My system has endpoints as numerical extensions, from 101 to 110. When a new endpoint registers with kamailio (and authenticates), I would like to send the REGISTER to Asterisk. But I have the following questions:</div><div><br></div><div>(a) Which Asterisk? I could send it to a round-robinned Asterisk (say, Asterisk_2), but that Asterisk may not be the one responsible for handling calls outbound for the endpoint that just registered. Even if I use "hash over auth username" instead of round-robin (In <a href="http://www.kamailio.org/docs/modules/4.0.x/modules/dispatcher.html#idp16940048" target="_blank">http://www.kamailio.org/docs/modules/4.0.x/modules/dispatcher.html#idp16940048</a>, choose 5 for "alg", for example) that wont solve this problem as an outbound request may come from another Asterisk box which won't have the requisite registration information. Should I forward REGISTERs to all Asterisk boxes? Maybe I won't have to deal with this issue as I use realtime and so the REGISTER information, sent to one Asterisk box, is available to all Asterisk boxes after the write to the realtime DB. Is my understanding correct?</div><div><br></div><div>(b) How do I do this in kamailio.cfg? With some examples on the Internet for WITH_ASTERISK directive, I see that you do </div><div><br></div><div><div>route[REGFWD] {</div><div>        if(!is_method("REGISTER"))</div><div>        {</div><div>                return;</div><div>        }</div><div>        $var(rip) = $sel(cfg_get.asterisk.bindip);</div><div>        $uac_req(method)="REGISTER";</div><div>        $uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport) + ";transport=tcp";</div><div>        $uac_req(furi)="sip:" + $au + "@" + $var(rip);</div><div>        $uac_req(turi)="sip:" + $au + "@" + $var(rip);</div><div>        $uac_req(hdrs)="Contact: <sip:" + $au + "@"</div><div>                                + $sel(cfg_get.kamailio.bindip)</div><div>                                + ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";</div><div>        if($sel(contact.expires) != $null)</div><div>                $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";</div><div>        else</div><div>                $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";</div><div>        uac_req_send();</div><div>}</div></div><div><br></div><div>What is the equivalent for when you are using the dispatcher module and the kamailio.bindip and asterisk.bindip etc. are not set in the configuration, but instead should be procured from elsewhere?</div><div><br></div><div>Any help is appreciated.</div><div><br></div><div><br></div></div>
<br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>