I didn't mention that I did this on kamailio 4.4.

Cheers,

Diego

2017-03-20 16:38 GMT-03:00 Diego Nadares <dnadares@gmail.com>:
Hi Lucian,

I made a few changes like you and I think it's working. Loads dialogs and generate cdr. It needs more testing. The function  cdr_on_load it's copy and paste to avoid touching those params in on_create. A lot of improve is needed. 

diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index ceaf08a..59210e8 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -692,7 +692,7 @@ static int mod_init(void)
                        LM_ERR("failed to initialize the DB support\n");
                        return -1;
                }
-               run_load_callbacks();
+               //run_load_callbacks();
        }
 
        destroy_dlg_callbacks( DLGCB_LOADED );

########

diff --git a/modules/dialog/dlg_db_handler.c b/modules/dialog/dlg_db_handler.c
index e27f8b2..22d0f04 100644
--- a/modules/dialog/dlg_db_handler.c
+++ b/modules/dialog/dlg_db_handler.c
@@ -173,6 +173,7 @@ int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int
                        LM_ERR("unable to load the dialog data\n");
                        return -1;
                }
+               run_load_callbacks();
        }
        dialog_dbf.close(dialog_db_handle);
        dialog_db_handle = 0;


########

diff --git a/modules/acc/acc_cdr.c b/modules/acc/acc_cdr.c
index 73bdd45..81ad640 100644
--- a/modules/acc/acc_cdr.c
+++ b/modules/acc/acc_cdr.c
@@ -733,11 +733,79 @@ static void cdr_on_destroy( struct dlg_cell* dialog,
     LM_DBG("dialog '%p' destroyed!\n", dialog);
 }
 
+/* callback for loading a dialog from db. */
+static void cdr_on_load( struct dlg_cell* dialog,
+                           int type,
+                           struct dlg_cb_params* params)
+{
+
+    LM_ERR("ON LOAD\n");
+    if( !dialog)
+    {
+        LM_ERR( "invalid dialog\n!");
+        return;
+    }
+
+    if( cdr_enable == 0)
+    {
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_CONFIRMED, cdr_on_start, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog CONFIRM callback\n");
+       return;
+    }
+
+    if(_acc_cdr_on_failed==1) {
+           if( dlgb.register_dlgcb( dialog, DLGCB_FAILED, cdr_on_failed, 0, 0) != 0)
+           {
+                   LM_ERR("can't register create dialog FAILED callback\n");
+                   return;
+           }
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED, cdr_on_end, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog TERMINATED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED_CONFIRMED, cdr_on_end_confirmed, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog TERMINATED CONFIRMED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_EXPIRED, cdr_on_expired, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog EXPIRED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_DESTROY, cdr_on_destroy, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog DESTROY callback\n");
+        return;
+    }
+
+    LM_DBG("dialog '%p' created!", dialog);
+
+    if( set_start_time( dialog) != 0)
+    {
+        LM_ERR( "failed to set start time");
+        return;
+    }
+}
+
+
 /* callback for the creation of a dialog. */
 static void cdr_on_create( struct dlg_cell* dialog,
                            int type,
                            struct dlg_cb_params* params)
 {
+
+    LM_ERR("ON CREATE\n");
     if( !dialog || !params || !params->req)
     {
         LM_ERR( "invalid values\n!");
@@ -852,13 +920,19 @@ int init_cdr_generation( void)
         LM_ERR("can't load dialog API\n");
         return -1;
     }
-
-    if( dlgb.register_dlgcb( 0, DLGCB_CREATED, cdr_on_create, 0, 0) != 0)
+    //Loaded from db
+    if( dlgb.register_dlgcb( 0, DLGCB_LOADED, cdr_on_load, 0, 0) != 0)
     {
         LM_ERR("can't register create callback\n");
         return -1;
     }
 
+    if( dlgb.register_dlgcb( 0, DLGCB_CREATED, cdr_on_create, 0, 0) != 0)
+    {
+       LM_ERR("can't register create callback\n");
+       return -1;
+    }
+
     return 0;
 }
 


    if( cdr_enable == 0)
    {   
        return;
    }

    if( dlgb.register_dlgcb( dialog, DLGCB_CONFIRMED, cdr_on_start, 0, 0) != 0)
    {   
        LM_ERR("can't register create dialog CONFIRM callback\n");
        return;
    }



Diego.



2017-03-20 10:06 GMT-03:00 Kordován Szabolcs <koszab@gmail.com>:
Hi All,

I have tired your patch but it dosen't work. No any changes. :(

Regards,
Szabolcs

2017-03-16 15:36 GMT+01:00 Lucian Balaceanu <lucian.balaceanu@1and1.ro>:
Hello all,

Just created the pull request: https://github.com/kamailio/kamailio/pull/1036 in relation to this problem with the sketch of a solution.

Any input is appreciated,
Lucian


On 15.03.2017 15:17, Daniel-Constantin Mierla wrote:

Hello,

ok, good to know is someone tackling it.

Thanks,
Daniel


On 15/03/2017 12:14, Pawel Kuzak wrote:

Hello,

This indeed is a bug we've also spotted. It is not only present in 5.0. It seems the run_create_callbacks() function which triggers the DLGCB_CREATED callbacks to be executed is not called for dialogs created from database. We are already working on a fix and are currently testing it. We will try push it upstream as soon as possible. We will answer on this thread when a fix is upstream.

Regards,
Paul


Am 14.03.2017 um 22:00 schrieb Kordován Szabolcs:
Hello Daniel,

Sorry for my reply, I didn't receive your mail.
So, only the active calls are affected. The new call, from invite to bye-ok, is recorded into table acc and acc_cdrs.

Regards,
Szabolcs

2017-03-14 11:13 GMT+01:00 Kordován Szabolcs <koszab@gmail.com>:
Hi,

I use acc module for create cdr into db and also make acc log into db.
After restart Kamailio cdr won't be created but acc log will be inserted into db. In the syslog also I see just the acc log. The dialog will be remove from db.

I have read many threads. I know that it should work.

Thanks for help!
Regards,
Szabolcs

From my configs:

#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3

modparam("acc", "db_url", DBURL)
modparam("acc", "db_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "db_extra", "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")

modparam("acc", "log_level", 3)
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "log_missed_flag", FLT_ACCMISSED)

modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "early_media", 1)

modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)

modparam("acc", "acc_prepare_always", 1)
modparam("acc", "time_mode", 1)
modparam("acc", "time_attr", "seconds")
modparam("acc", "time_exten", "microsecs")
modparam("acc", "reason_from_hf", 1)

modparam("acc", "cdr_enable", 1)
modparam("acc", "cdr_expired_dlg_enable", 1)
modparam("acc", "cdr_start_on_confirmed", 1)
modparam("acc", "cdrs_table", "acc_cdrs")
modparam("acc", "cdr_on_failed", 1) 
modparam("acc", "cdr_extra", "callid=$ci;src_user=$dlg_var(fU);src_domain=$dlg_var(fd);dst_ouser=$dlg_var(tU);dst_user=$dlg_var(rU);dst_domain=$dlg_var(rd);src_ip=$dlg_var(si);peer_in=$dlg_var(peerin);peer_out=$dlg_var(peerout)")

request_route {
<------>
<------>$var(loose) = loose_route();
<------>$var(check_trans) = t_check_trans();
<------>sip_trace();
<------>setflag(FLT_SIPTRACE);
<------>dlg_manage();

<------># handle retransmissions
<------>if(t_precheck_trans()) {
<------>    xlogl("LOG_LOCAL0", "L_ALERT", "================== kamaty $rm route $ci ==== $rm ==== precheck_trans exit\n");
<------>    exit;
<------>}

<------>if(is_method("OPTIONS")) {.
<------>    # send reply for each options request.
<------>    sl_send_reply("200", "ok");.
<------>    exit();.
<------>}
<------># CANCEL processing
<------>if (is_method("CANCEL")) {
<------><------>if (t_check_trans()) {
<------><------>    route(RELAY);
<------><------>}
<------><------>exit;
<------>}
<------>if ( is_method("ACK") ) {
<------><------>if ( $var(check_trans) ) {
<------><------>    route(RELAY);
<------><------>}
<------><------>exit;
<------>}
<------>if (is_method("BYE")) {
<------>    if ($var(loose)) {
<------><------>setflag(FLT_ACC); # do accounting ...
<------><------>setflag(FLT_ACCFAILED); # ... even if the transaction fails
<------><------>setflag(FLT_ACCMISSED);
<------><------>route(RELAY);
<------>    <-->exit;
<------>    }
<------>    exit;
<------>}
etc.




_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - www.asipto.com
Kamailio World Conference - May 8-10, 2017 - www.kamailioworld.com


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users