The dialog event route should have the $dlg(...) variable available that you should use as input in an sql_query():

- http://www.kamailio.org/wiki/cookbooks/4.1.x/pseudovariables#dialog_module_pseudo-variables

At timeout there is no request there. It is the event that triggers tm to build and send a bye, to be available in tm:local-request

Cheers,
Daniel

On 05/08/14 09:00, betul.cerit@netgsm.com.tr wrote:
Hi, In ‘event_route[dialog:end]’I can not get any variable they are all empty but using acc_db_requests() worked for me. Thanks for your help. BEST REGARDS From: Daniel-Constantin Mierla Sent: Monday, August 04, 2014 5:28 PM To: Kamailio (SER) - Users Mailing List Subject: Re: [SR-Users] missing BYE record on acc table when usingtimeout_avp Hello,

with latest version you can get the cdrs at once via dialog+acc module.

If you want to use the classic acc, then add either event_route[dialog:end] or event_route[tm:local-request]. There you can get actions when the dialog is ended  (including the time out), and for the second you get the BYE sent out. Perhaps SQLOPS with sql_query() or acc_db_requests() should be used to record the event in db table.

Cheers,
Daniel

On 04/08/14 15:19, betul.cerit@netgsm.com.tr wrote:
Hi to all, I want to limit call duration according to the credit of the user.To accomplish this I use timeout_avp .When the limit is reached call ends but no record associated with BYE method is inserted to the acc table and that makes impossible to bill that call.What can I do to solve this problem or is there an alternative way to limit call duration?My configuration and logs are as follows. BEST REGARDS. #---------------- dialog params ------------- #!ifdef WITH_DIALOG modparam("dialog", "enable_stats", 1) modparam("dialog", "hash_size", 8192) modparam("dialog", "rr_param", "did") modparam("dialog", "dlg_flag",4) modparam("dialog", "timeout_avp", "$avp(i:10)") modparam("dialog", "dlg_match_mode", 1) modparam("dialog", "default_timeout", 3600) modparam("dialog", "detect_spirals", 1) modparam("dialog", "profiles_with_value", "userid ; opkodu") modparam("dialog", "dlg_extra_hdrs", "Hint: Hell Yeah\r\n") modparam("dialog", "send_bye", 1) #endif -------------------------------------------------------------------------------- route[SW]{ xlog("L_INFO","Dialog:h_id:$dlg(h_id):h_entry:$dlg(h_entry):timeout:$dlg_ctx(timeout_route):bye:$dlg_ctx(timeout_bye):$avp(i:10)");                 $dlg_ctx(timeout_bye)=1;                 $avp(i:10)=15;                 $dlg_ctx(timeout_route)=33;                  dlg_manage();                  set_dlg_profile("userid","$avp(userid)");                 if(get_profile_size("userid","$avp(s_userid)")){                         xlog("L_INFO","Userid_Size:$avp(s_userid)");                 } xlog("L_INFO","Dialog:h_id:$dlg(h_id):h_entry:$dlg(h_entry):timeout:$dlg_ctx(timeout_route):bye:$dlg_ctx(timeout_bye):$avp(i:10)");         if(!t_relay()) {                  send_reply("408", "Servis Disi");         }else{                  exit;         }         return; } event_route[dialog:start]{         xlog("L_ALERT","START:ci:$ci:method:$rm:start"); } event_route[dialog:end]{         xlog("L_ALERT","END");         xlog("L_ALERT","END:$fU:$fd:$si:$rU:$rd:$avp(poparty):$avp(networkdatetime):$avp(ptparty):$avp(pprovider):$avp(maliyet_id):$avp(tibtip)");         xlog("L_ALERT","END:$rm:$rr:$rs:"); } event_route[dialog:failed]{         xlog("L_INFO","FAILED:ci:$ci:method:$rm:end"); } route[33]{         xlog("L_INFO","route:33:$fU:$fd:$si:$rU:$rd:$avp(poparty):$avp(networkdatetime):$avp(ptparty):$avp(pprovider):$avp(maliyet_id):$avp(tibtip)");         xlog("L_INFO","route:33:$rm:$rr:$rs:"); } # Handle requests within SIP dialogs route[WITHINDLG] {         if (has_totag()) {                 # sequential request withing a dialog should                 # take the path determined by record-routing                 if (loose_route()) {                         route(DLGURI);                         if (is_method("BYE")) {                                 setflag(FLT_ACC); # do accounting ...                                 setflag(FLT_ACCFAILED); # ... even if the transaction fails                         }                         else if ( is_method("ACK") ) {                                 # ACK is forwarded statelessy                                 route(NATMANAGE);                         }                         else if ( is_method("NOTIFY") ) {                                 # Add Record-Route for in-dialog NOTIFY as per RFC 6665.                                 record_route();                         }                         route(RELAY);                 } else {                         if (is_method("SUBSCRIBE") && uri == myself) {                                 # in-dialog subscribe requests                                 route(PRESENCE);                                 exit;                         }                         if ( is_method("ACK") ) {                                 if ( t_check_trans() ) {                                         # no loose-route, but stateful ACK;                                         # must be an ACK after a 487                                         # or e.g. 404 from upstream server                                         route(RELAY);                                         exit;                                 } else {                                         # ACK without matching transaction ... ignore and discard                                         exit;                                 }                         }          sl_send_reply("404","Not here");                 }                 exit;         } } -------------------------------------------------------------------------------- Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: ALERT: <script>: USERID:456123 Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: ALERT: <script>: arayan:XXXX:aranan:XXXXX Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: INFO: carrierroute [cr_func.c:710]: cr_do_route(): uri XXXX was rewritten to sip:YYYYYYYYYYYYYYY@XXXXXXX5:5060, carrier 3, domain 1 Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: INFO: <script>: vardesc: 40 Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: INFO: <script>: Dialog:h_id:<null>:h_entry:<null>:timeout:0:bye:0:<null> Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: INFO: <script>: Userid_Size:1 Aug  1 16:51:52 kamailio /usr/local/sbin/kamailio[6111]: INFO: <script>: Dialog:h_id:3953:h_entry:3170:timeout:14:bye:1:15 Aug  1 16:51:55 kamailio /usr/local/sbin/kamailio[6114]: ALERT: <script>: START:ci:2c5695c1644fa2b135f57ea72c590cc7@XXXXXXX:5060:method:INVITE:start Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: <core> [parser/parse_from.c:113]: parse_from_uri(): failed to parse From uri Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: pv [pv_core.c:397]: pv_get_xto_attr(): cannot parse From URI Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: <core> [parser/parse_from.c:113]: parse_from_uri(): failed to parse From uri Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: pv [pv_core.c:397]: pv_get_xto_attr(): cannot parse From URI Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: INFO: <script>: route:33:<null>:<null>:1.0.0.127:you:kamailio.org:<null>:<null>:<null>:<null>:<null>:<null> Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: INFO: <script>: route:33:OPTIONS:<null>:<null>: Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ALERT: <script>: END Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: <core> [parser/parse_from.c:113]: parse_from_uri(): failed to parse From uri Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: pv [pv_core.c:397]: pv_get_xto_attr(): cannot parse From URI Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: <core> [parser/parse_from.c:113]: parse_from_uri(): failed to parse From uri Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ERROR: pv [pv_core.c:397]: pv_get_xto_attr(): cannot parse From URI Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ALERT: <script>: END:<null>:<null>:1.0.0.127:you:kamailio.org:<null>:<null>:<null>:<null>:<null>:<null> Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6145]: ALERT: <script>: END:OPTIONS:<null>:<null>: Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6121]: WARNING: dialog [dlg_req_within.c:212]: bye_reply_cb(): inconsitent dlg timer data on dlg 0x7feb2115d918 [3170:3953] with clid '2c5695c1644fa2b135f57ea72c590cc7@95.0.154.92:5060' and tags 'as3c7c5aa4' 'as0b640624' Aug  1 16:52:11 kamailio /usr/local/sbin/kamailio[6121]: ERROR: acc [acc_cdr.c:574]: cdr_on_end(): invalid values#012! BTLCRT

_______________________________________________
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 - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


_______________________________________________
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 - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda