Hello. I try to do my own dispatcher with redis db. I have problem with disconnecting module wrom redis. Redis server is remote microsoft public server. This good solution for many companies and it works stable
THe FIrst Isuue I saw when used

modparam("ndb_redis", "server", "name=srv1;addr=non_local_serv;port=6379;db=4;pass=mypass")

[TOASTERISK]
redis_cmd("srv1", "EXISTS $si", "s");
xlog("L_INFO","ASTERISK with ip $si is {$redis(s=>value)}");

$var(setid)=0;
if ($redis(s=>value) == 0) {    
      xlog("L_INFO","Request {$rm} from $si != {$var(dest)} It means call NOT from ASTRISK");
    }

And when this call begins I get s value. But If I EXISTS it from redis comsole there is successfull reply.

Sometimes I see this at kamailio log

redisc_exec(): Redis error: Server closed the connection

I tried MONITOR redis from cli, but nothing happends when disconnect. (nothing means -nothing at the cli)

So I tried one more thing:
I have some pools of requests
1. When options recieved to kam from asterisk

if (is_method("OPTIONS"))
{
if ($sp == 50600) {

            redis_cmd("srv1", "AUTH mylonglongpass"","r")
            redis_cmd("srv1", "SET $si $TS", "r");
            redis_cmd("srv1", "EXPIRE $si 20", "r");

        }

}

It works fine (Intresting that this works fine with the PASS through modparam key too)

Second pool when KAmailio choose ASTERISK to send INVITE from redis

    #DISPATCHER_NEW 
            #$setid - is another var that gets from sql db.
    $var(priority)=1;
    redis_cmd("srv1", "AUTH mylonglongpass", "p");

           while ($redis(b=>value) == 0)
    {
    xlog("L_INFO","{$rm} priority now is $var(priority) and setid $var(setid)\n");
    redis_cmd("srv1", "EXISTS $var(setid):$var(priority)", "e");
    xlog("L_INFO","ASTERISK with customer $var(setid) and priority $var(priority) id {$redis(e=>value)} (if 1 - exists, 0 - not exisits)");

Regis correctly get reply always

    if ($redis(e=>value) == 1)
    {
        redis_cmd("srv1", "GET $var(setid):$var(priority)", "a"); 

               #get IP of asterisk. Always get right value too

xlog("L_INFO","ASTERISK with customer $var(setid) and priority $var(priority)  is {$redis(a=>value)} (if 0 - not exisits)");
        redis_cmd("srv1", "GET $redis(a=>value)", "b"); #check timestamp that set at redis OPTION request

There are I have truble when use AUTH command because redis return after GET. If i do GET from cli - all ok.

        xlog("L_INFO","ASTERISK with customer $var(setid) and priority $var(priority) have timestamp {$redis(b=>value)} (if null - no timestamp. This means it down. Get new asterisk)");

        if ($redis(b=>value) == 1){

            $du="sip:"+$redis(a=>value)+":50600";
        }
        else{
            $var(priority)=$var(priority)+1;
            }
    }

Offcource I checked all parameteres - database name and another connection attrs of modparam


Reply to this email directly or view it on GitHub.