[SR-Users] kamailio 5.0 with asterisks

Samuel F. samuel_is_kewl at hotmail.com
Thu Jul 20 09:28:10 CEST 2017

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 at lists.kamailio.org> on behalf of Aidar Kamalov <aidar.kamalov at gmail.com>
Sent: Thursday, July 20, 2017 6:31:37 AM
To: sr-users at lists.kamailio.org
Subject: [SR-Users] kamailio 5.0 with asterisks


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 at sipchel ~]# kamctl ul show 101
  "jsonrpc":  "2.0",
  "result": {
    "AoR":  "101",
    "Contacts": [{
        "Contact":  {
          "Address":  "sip:101 at<mailto:sip%3A101 at>;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:<>",
          "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 at sipchel ~]# kamctl dispatcher dump
  "jsonrpc":  "2.0",
  "result": {
    "NRSETS": 1,
    "RECORDS":  [{
        "SET":  {
          "ID": 1,
          "TARGETS":  [{
              "DEST": {
                "URI":  "sip:",
                "FLAGS":  "IX",
                "PRIORITY": 0
            }, {
              "DEST": {
                "URI":  "sip:",
                "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)
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

<------># NAT detection

<------># CANCEL processing
<------>if (is_method("CANCEL")) {
<------><------>if (t_check_trans()) {

<------># handle retransmissions
<------>if (!is_method("ACK")) {
<------><------>if(t_precheck_trans()) {

<------># handle requests within SIP dialogs

<------>### only initial requests (no To tag)

<------># authentication

<------># record routing for dialog forming requests (in case they are routed)
<------># - remove preloaded route headers
<------>if (is_method("INVITE|SUBSCRIBE")) {

<------># account only INVITEs
<------>if (is_method("INVITE")) {
<------><------>setflag(FLT_ACC); # do accounting

<------># dispatch requests to foreign domains
------>### requests for my local domains

<------># handle presence related requests

<------># handle registrations

<------>if ($rU==$null) {
<------><------># request with no Username in RURI
<------><------>sl_send_reply("484","Address Incomplete");

<------># dispatch destinations to PSTN

<------># user location service

# User location service
route[LOCATION] {

<------># search for short dialing - 2-digit extension
<------>if($rU=~"^[0-9][0-9]$") {
<------><------>if(sd_lookup("speed_dial")) {

<------># search in DB-based aliases
<------>if(alias_db_lookup("dbaliases")) {

<------>$avp(oexten) = $rU;
<------>if (!lookup("location")) {
<------><------>$var(rc) = $rc;
<------><------>switch ($var(rc)) {
<------><------><------>case -1:
<------><------><------>case -3:
<------><------><------><------>send_reply("404", "Not Found");
<------><------><------>case -2:
<------><------><------><------>send_reply("405", "Method Not Allowed");

<------># when routing via usrloc, log the missed calls also
<------>if (is_method("INVITE")) {


# 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");

Aydar A. Kamalov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20170720/6f706b43/attachment.html>

More information about the sr-users mailing list