Hi Aidar,
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.
Try update your config following way:
change "route(DISPATCH);" line with flowing code:
if(!ds_is_from_list()) {
route(DISPATCH);
}
Additionally you can save registrations on Asterisk side using path.
With kind regards,
Jurijs
On Thu, Jul 20, 2017 at 10:28 AM, Samuel F. <samuel_is_kewl(a)hotmail.com>
wrote:
This seems to be an Asterisk issue and not Kamailio
issue.
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.
I would suggest that you do a verbose console connection to the Asterisk
and check which context the INVITE ends up in.
Most likely you will need to change the peer type and perhaps identify it
by IP so it doesn't have to register.
// Samuel
------------------------------
*From:* sr-users <sr-users-bounces(a)lists.kamailio.org> on behalf of Aidar
Kamalov <aidar.kamalov(a)gmail.com>
*Sent:* Thursday, July 20, 2017 6:31:37 AM
*To:* sr-users(a)lists.kamailio.org
*Subject:* [SR-Users] kamailio 5.0 with asterisks
Hello!
I'm new with kamailio, so may be don't understand some basic.
I'm tryin to load balance asterisk servers with kamailio and dispatcher
module. My ip phones registered at kamailio, for example:
[root@sipchel ~]# kamctl ul show 101
{
"jsonrpc": "2.0",
"result": {
"AoR": "101",
"Contacts": [{
"Contact": {
"Address": "sip:101@192.168.2.62;line=4733c4bfa459eea",
"Expires": 2953,
"Q": -1,
"Call-ID": "1361221648",
"CSeq": 136,
"User-Agent": "Linphone/3.6.1 (eXosip2/3.6.0)",
"Received": "[not set]",
"Path": "[not set]",
"State": "CS_SYNC",
"Flags": 0,
"CFlags": 0,
"Socket": "udp:192.168.10.54:5060",
"Methods": -1,
"Ruid": "uloc-596f5abc-2ce5-2",
"Instance": "[not set]",
"Reg-Id": 0,
"Last-Keepalive": 1500530337,
"Last-Modified": 1500530337
}
}]
},
"id": 15024
}
I have realtime asterisk server.
[root@sipchel ~]# kamctl dispatcher dump
{
"jsonrpc": "2.0",
"result": {
"NRSETS": 1,
"RECORDS": [{
"SET": {
"ID": 1,
"TARGETS": [{
"DEST": {
"URI": "sip:192.168.4.16",
"FLAGS": "IX",
"PRIORITY": 0
}
}, {
"DEST": {
"URI": "sip:192.168.10.47",
"FLAGS": "AX",
"PRIORITY": 0
}
}]
}
}]
},
"id": 15087
}
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)
[kamailio]
exten => _1XX,1,Dial(SIP/${EXTEN})
exten => _1XX,n,Hangup
If I change dialplan to Dial(SIP/KAMAILIO/${EXTEN}) call wil return to
kamailio, but kamailio send it back to asterisk...
I hope I explained correctly, my English is terrible.
Is my screnario proper? How this usually done? Should I forward sip
registrations to asterisks?
My kamailio config
# dispatcher params
modparam("dispatcher", "db_url", "mysql://kamailio:kamailiorw@
localhost/kamailio")
modparam("dispatcher", "ds_ping_interval", 30)
modparam("dispatcher", "table_name", "dispatcher")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
modparam("auth_db", "db_url", DBASTURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "user_column", "name")
modparam("auth_db", "password_column", "sippasswd")
modparam("auth_db", "load_credentials", "")
#modparam("auth_db", "version_table", 0)
request_route {
<------># per request initial checks
<------>route(REQINIT);
<------># NAT detection
<------>route(NATDETECT);
<------># CANCEL processing
<------>if (is_method("CANCEL")) {
<------><------>if (t_check_trans()) {
<------><------><------>route(RELAY);
<------><------>}
<------><------>exit;
<------>}
<------># handle retransmissions
<------>if (!is_method("ACK")) {
<------><------>if(t_precheck_trans()) {
<------><------><------>t_check_trans();
<------><------><------>exit;
<------><------>}
<------><------>t_check_trans();
<------>}
<------># handle requests within SIP dialogs
<------>route(WITHINDLG);
<------>### only initial requests (no To tag)
<------># authentication
<------>route(AUTH);
<------># record routing for dialog forming requests (in case they are
routed)
<------># - remove preloaded route headers
<------>remove_hf("Route");
<------>if (is_method("INVITE|SUBSCRIBE")) {
<------><------>record_route();
<------>}
<------># account only INVITEs
<------>if (is_method("INVITE")) {
<------><------>setflag(FLT_ACC); # do accounting
<------>}
<------># dispatch requests to foreign domains
<------>route(SIPOUT);
------>### requests for my local domains
<------># handle presence related requests
<------>route(PRESENCE);
<------># handle registrations
<------>route(REGISTRAR);
<------>if ($rU==$null) {
<------><------># request with no Username in RURI
<------><------>sl_send_reply("484","Address
Incomplete");
<------><------>exit;
<------>}
<------># dispatch destinations to PSTN
<------>route(PSTN);
<------># user location service
<------>route(LOCATION);
}
# User location service
route[LOCATION] {
#!ifdef WITH_SPEEDDIAL
<------># search for short dialing - 2-digit extension
<------>if($rU=~"^[0-9][0-9]$") {
<------><------>if(sd_lookup("speed_dial")) {
<------><------><------>route(SIPOUT);
<------><------>}
<------>}
#!endif
#!ifdef WITH_ALIASDB
<------># search in DB-based aliases
<------>if(alias_db_lookup("dbaliases")) {
<------><------>route(SIPOUT);
<------>}
#!endif
<------>$avp(oexten) = $rU;
<------>if (!lookup("location")) {
<------><------>$var(rc) = $rc;
<------><------>route(TOVOICEMAIL);
<------><------>t_newtran();
<------><------>switch ($var(rc)) {
<------><------><------>case -1:
<------><------><------>case -3:
<------><------><------><------>send_reply("404",
"Not Found");
<------><------><------><------>exit;
<------><------><------>case -2:
<------><------><------><------>send_reply("405",
"Method Not Allowed");
<------><------><------><------>exit;
<------><------>}
<------>}
<------># when routing via usrloc, log the missed calls also
<------>if (is_method("INVITE")) {
<------><------>setflag(FLT_ACCMISSED);
<------>}
route(DISPATCH);
<------>route(RELAY);
<------>exit;
}
# Dispatch requests
route[DISPATCH] {
<------># round robin dispatching on gateways group '1'
<------>if(!ds_select_dst("1", "4"))
<------>{
<------> xlog("aaaa--- SCRIPT: going to <$ru> via
<$du>\n");
<------> send_reply("404", "No destination");
<------> exit;
<------>}
<------>xlog("--- SCRIPT: going to <$ru> via <$du>\n");
<------>t_on_failure("RTF_DISPATCH");
<------>return;
}
--
Aydar A. Kamalov
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users