My object:    get the dialog-based CDRs
 
SIP proxy:   kamailio-3.2.0
 
My script:
 
loadmodule "dialog.so"
......
modparam("dialog","dlg_flag",4)#Must be set to create the dialog associated to an initial request.
modparam("dialog","db_url","mysql://xxx:xxx@localhost/albert")
modparam("dialog","table_name","dialog")
.......
request_route{
    if( is_method("INVITE") && !has_totag())
    {
           dlg_setflag(4);
           dlg_var(start_time)=$TS;
           dlg_var(caller)=$fU;
           dlg_var(caller)=$tU;
    } 
    dlg_manage();
    ......
    # dispatch destinations to PSTN
     route(PSTN);
    # user location service
      route(LOCATION);
      route(RELAY);
}
.........
route[WITHINDLG] {
     if (has_totag()) {
             # sequential request withing a dialog should
             # take the path determined by record-routing
     if (loose_route()) {
              if (is_method("BYE")) {
                    setflag(FLT_ACC); # do accounting ...
                   setflag(FLT_ACCFAILED); # ... even if the transaction fails
       
                   sql_query("cd", "insert into cdr(caller,callee,start_time,duration) values($dlg_var(caller),$dlg_var(callee),$dlg_var(start_time),$DLG_lifetime)", "rd");
                   sql_result_free("rd");   
     }
     if (is_method("ACK")) {
     route(NATMANAGE); # ACK is forwarded statelessy
    }
    route(RELAY);
}
........
 
 
My issue is :
 
        The dialog records can be wrritten into the dialog table.  But , the sql_query can not executed. So the cdr table will not get the CDRs.  I don't know why. Who can help me ?

        This is a simple script for testing. 

        Any suggestion will be appreciated.

        Thank you in advance.

 
------------------
albert.gu