<div dir="ltr"><div><div><div>Hi Aidar,<br><br></div>Your approach should work. So basically calls from Asterisk should be routed to destination what is found in location table and calls not from Asterisk to Asterisk servers.<br><br></div>Try update your config following way:<br><br></div>change "route(DISPATCH);" line with flowing code:<br><div><br>if(!ds_is_from_list()) {<br><br>        route(DISPATCH);<br>}<br><br></div><div>Additionally you can save registrations on Asterisk side using path.<br><br><a href="https://www.kamailio.org/docs/modules/4.4.x/modules/path.html">https://www.kamailio.org/docs/modules/4.4.x/modules/path.html</a><br><br></div><div>My sample config using path:<br><br><a href="https://github.com/os11k/dispatcher">https://github.com/os11k/dispatcher</a><br></div><div><br></div><div>With kind regards,<br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Jurijs<br></div></div></div>
<br><div class="gmail_quote">On Thu, Jul 20, 2017 at 10:28 AM, Samuel F. <span dir="ltr"><<a href="mailto:samuel_is_kewl@hotmail.com" target="_blank">samuel_is_kewl@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>

<div id="m_-3606080014876918803divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>This seems to be an Asterisk issue and not Kamailio issue.</p>
<p><br>
</p>
<p>In particular, it seems that you haven't set up your peer configuration in Asterisk in such a way that it matches towards the Kamailio context.</p>
<p><br>
</p>
<p>I would suggest that you do a verbose console connection to the Asterisk and check which context the INVITE ends up in.</p>
<p><br>
</p>
<p>Most likely you will need to change the peer type and perhaps identify it by IP so it doesn't have to register.</p>
<p><br>
</p>
<p>// Samuel</p>
</div>
<hr style="display:inline-block;width:98%">
<div id="m_-3606080014876918803divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org" target="_blank">sr-users-bounces@lists.<wbr>kamailio.org</a>> on behalf of Aidar Kamalov <<a href="mailto:aidar.kamalov@gmail.com" target="_blank">aidar.kamalov@gmail.com</a>><br>
<b>Sent:</b> Thursday, July 20, 2017 6:31:37 AM<br>
<b>To:</b> <a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<b>Subject:</b> [SR-Users] kamailio 5.0 with asterisks</font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="ltr">Hello!
<div><br>
</div>
<div>I'm new with kamailio, so may be don't understand some basic.</div>
<div>I'm tryin to load balance asterisk servers with kamailio and dispatcher module. My ip phones registered at kamailio, for example:</div>
<div>
<div><br>
</div>
<div>[root@sipchel ~]# kamctl ul show 101</div>
<div>{<br>
</div>
<div>  "jsonrpc":  "2.0",</div>
<div>  "result": {</div>
<div>    "AoR":  "101",</div>
<div>    "Contacts": [{</div>
<div>        "Contact":  {</div>
<div>          "Address":  "<a href="mailto:sip%3A101@192.168.2.62" target="_blank">sip:101@192.168.2.62</a>;line=<wbr>4733c4bfa459eea",</div>
<div>          "Expires":  2953,</div>
<div>          "Q":  -1,</div>
<div>          "Call-ID":  "1361221648",</div>
<div>          "CSeq": 136,</div>
<div>          "User-Agent": "Linphone/3.6.1 (eXosip2/3.6.0)",</div>
<div>          "Received": "[not set]",</div>
<div>          "Path": "[not set]",</div>
<div>          "State":  "CS_SYNC",</div>
<div>          "Flags":  0,</div>
<div>          "CFlags": 0,</div>
<div>          "Socket": "udp:<a href="http://192.168.10.54:5060" target="_blank">192.168.10.54:5060</a>",</div>
<div>          "Methods":  -1,</div>
<div>          "Ruid": "uloc-596f5abc-2ce5-2",</div>
<div>          "Instance": "[not set]",</div>
<div>          "Reg-Id": 0,</div>
<div>          "Last-Keepalive": 1500530337,</div>
<div>          "Last-Modified":  1500530337</div>
<div>        }</div>
<div>      }]</div>
<div>  },</div>
<div>  "id": 15024</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>I have realtime asterisk server.</div>
<div>
<div>[root@sipchel ~]# kamctl dispatcher dump</div>
<div>{<br>
</div>
<div>  "jsonrpc":  "2.0",</div>
<div>  "result": {</div>
<div>    "NRSETS": 1,</div>
<div>    "RECORDS":  [{</div>
<div>        "SET":  {</div>
<div>          "ID": 1,</div>
<div>          "TARGETS":  [{</div>
<div>              "DEST": {</div>
<div>                "URI":  "sip:192.168.4.16",</div>
<div>                "FLAGS":  "IX",</div>
<div>                "PRIORITY": 0</div>
<div>              }</div>
<div>            }, {</div>
<div>              "DEST": {</div>
<div>                "URI":  "sip:192.168.10.47",</div>
<div>                "FLAGS":  "AX",</div>
<div>                "PRIORITY": 0</div>
<div>              }</div>
<div>            }]</div>
<div>        }</div>
<div>      }]</div>
<div>  },</div>
<div>  "id": 15087</div>
<div>}</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>So I want if 101 call to 102 it will process by asterisk(for call recording and other features). Now if I call from 101 to 102 kamailio will forward to asterisk and asterisk dialplan cannot find that extesion(as expected, because it is not registed on
 asterisk)</div>
</div>
<div>
<div>[kamailio]</div>
<div>exten => _1XX,1,Dial(SIP/${EXTEN})</div>
<div>exten => _1XX,n,Hangup</div>
</div>
<div>If I change dialplan to Dial(SIP/KAMAILIO/${EXTEN}) call wil return to kamailio, but kamailio send it back to asterisk...</div>
<div>
<div><br>
</div>
<div>I hope I explained correctly, my English is terrible.</div>
</div>
<div>Is my screnario proper? How this usually done? Should I forward sip registrations to asterisks?</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>My kamailio config</div>
<div>
<div># dispatcher params</div>
<div>modparam("dispatcher", "db_url", "mysql://kamailio:kamailiorw@<wbr>localhost/kamailio")</div>
<div>modparam("dispatcher", "ds_ping_interval", 30)</div>
<div>modparam("dispatcher", "table_name", "dispatcher")</div>
<div>modparam("dispatcher", "flags", 2)</div>
<div>modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")</div>
<div>modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")</div>
<div>modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")</div>
</div>
<div><br>
</div>
<div>
<div>modparam("auth_db", "db_url", DBASTURL)</div>
<div>modparam("auth_db", "calculate_ha1", yes)</div>
<div>modparam("auth_db", "user_column", "name")</div>
<div>modparam("auth_db", "password_column", "sippasswd")</div>
<div>modparam("auth_db", "load_credentials", "")</div>
<div>#modparam("auth_db", "version_table", 0)</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div>request_route {</div>
<div><br>
</div>
<div><------># per request initial checks</div>
<div><------>route(REQINIT);</div>
<div><br>
</div>
<div><------># NAT detection</div>
<div><------>route(NATDETECT);</div>
<div><br>
</div>
<div><------># CANCEL processing</div>
<div><------>if (is_method("CANCEL")) {</div>
<div><------><------>if (t_check_trans()) {</div>
<div><------><------><------>route(<wbr>RELAY);</div>
<div><------><------>}</div>
<div><------><------>exit;</div>
<div><------>}</div>
<div><br>
</div>
<div><------># handle retransmissions</div>
<div><------>if (!is_method("ACK")) {</div>
<div><------><------>if(t_precheck_<wbr>trans()) {</div>
<div><------><------><------>t_<wbr>check_trans();</div>
<div><------><------><------>exit;</div>
<div><------><------>}</div>
<div><------><------>t_check_trans(<wbr>);</div>
<div><------>}</div>
<div><br>
</div>
<div><------># handle requests within SIP dialogs</div>
<div><------>route(WITHINDLG);</div>
<div><br>
</div>
<div><------>### only initial requests (no To tag)</div>
<div><br>
</div>
<div><------># authentication</div>
<div><------>route(AUTH);</div>
<div><br>
</div>
<div><------># record routing for dialog forming requests (in case they are routed)</div>
<div><------># - remove preloaded route headers</div>
<div><------>remove_hf("Route");</div>
<div><------>if (is_method("INVITE|SUBSCRIBE")<wbr>) {</div>
<div><------><------>record_route()<wbr>;</div>
<div><------>}</div>
<div><br>
</div>
<div><------># account only INVITEs</div>
<div><------>if (is_method("INVITE")) {</div>
<div><------><------>setflag(FLT_<wbr>ACC); # do accounting</div>
<div><------>}</div>
<div><br>
</div>
<div><------># dispatch requests to foreign domains</div>
<div><------>route(SIPOUT);</div>
</div>
<div>
<div>------>### requests for my local domains</div>
<div><br>
</div>
<div><------># handle presence related requests</div>
<div><------>route(PRESENCE);</div>
<div><br>
</div>
<div><------># handle registrations</div>
<div><------>route(REGISTRAR);</div>
<div><br>
</div>
<div><------>if ($rU==$null) {</div>
<div><------><------># request with no Username in RURI</div>
<div><------><------>sl_send_reply(<wbr>"484","Address Incomplete");</div>
<div><------><------>exit;</div>
<div><------>}</div>
<div><br>
</div>
<div><------># dispatch destinations to PSTN</div>
<div><------>route(PSTN);</div>
<div><br>
</div>
<div><------># user location service</div>
<div><------>route(LOCATION);</div>
<div>}</div>
</div>
<div><br>
</div>
<div># User location service</div>
<div>route[LOCATION] {</div>
<div><br>
</div>
<div>#!ifdef WITH_SPEEDDIAL</div>
<div><------># search for short dialing - 2-digit extension</div>
<div><------>if($rU=~"^[0-9][0-9]$"<wbr>) {</div>
<div><------><------>if(sd_lookup("<wbr>speed_dial")) {</div>
<div><------><------><------>route(<wbr>SIPOUT);</div>
<div><------><------>}</div>
<div><------>}</div>
<div>#!endif</div>
<div><br>
</div>
<div>#!ifdef WITH_ALIASDB</div>
<div><------># search in DB-based aliases</div>
<div><------>if(alias_db_lookup("<wbr>dbaliases")) {</div>
<div><------><------>route(SIPOUT);</div>
<div><------>}</div>
<div>#!endif</div>
<div><br>
</div>
<div><------>$avp(oexten) = $rU;</div>
<div><------>if (!lookup("location")) {</div>
<div><------><------>$var(rc) = $rc;</div>
<div><------><------>route(<wbr>TOVOICEMAIL);</div>
<div><------><------>t_newtran();</div>
<div><------><------>switch ($var(rc)) {</div>
<div><------><------><------>case -1:</div>
<div><------><------><------>case -3:</div>
<div><------><------><------><-----<wbr>->send_reply("404", "Not Found");</div>
<div><------><------><------><-----<wbr>->exit;</div>
<div><------><------><------>case -2:</div>
<div><------><------><------><-----<wbr>->send_reply("405", "Method Not Allowed");</div>
<div><------><------><------><-----<wbr>->exit;</div>
<div><------><------>}</div>
<div><------>}</div>
<div><br>
</div>
<div><------># when routing via usrloc, log the missed calls also</div>
<div><------>if (is_method("INVITE")) {</div>
<div><------><------>setflag(FLT_<wbr>ACCMISSED);</div>
<div><------>}</div>
<div><br>
</div>
<div>        route(DISPATCH);</div>
<div><------>route(RELAY);</div>
<div><------>exit;</div>
<div>}</div>
<div><br>
</div>
</div>
<div>
<div># Dispatch requests</div>
<div>route[DISPATCH] {</div>
<div><------># round robin dispatching on gateways group '1'</div>
<div><------>if(!ds_select_dst("1", "4"))</div>
<div><------>{</div>
<div><------>    xlog("aaaa--- SCRIPT: going to <$ru> via <$du>\n");</div>
<div><------>    send_reply("404", "No destination");</div>
<div><------>    exit;</div>
<div><------>}</div>
<div><------>xlog("--- SCRIPT: going to <$ru> via <$du>\n");</div>
<div><------>t_on_failure("RTF_<wbr>DISPATCH");</div>
<div><------>return;</div>
<div>}</div>
</div>
<div><br>
</div>
<div><br>
</div>
-- <br>
<div class="m_-3606080014876918803gmail_signature">Aydar A. Kamalov</div>
</div>
</div>
</div>
</div></div></div>

<br>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br></blockquote></div><br></div>