[SR-Users] Dialog module event_route problem

davy davy.van.de.moere at gmail.com
Tue Aug 12 16:28:29 CEST 2014


why don’t you hook your http_queries up to the relevant SIP packets passing by?

INVITE -> start
180/183 -> ringing
200 -> pickup
BYE/CANCEL -> end

It’s quite straightforward to get that cleanly in your configfile, and it give you a massive control over things. (just be aware of packets arriving twice ;)  )

Anyhow, that’s how I typically handle this one. You can always also combine it with CNXCC, which is great for prepaid! Or do something from external with dlg.dlg_end to kill specific calls which are going over their limit.

But, I’m sure others will have even better ideas !

Grtz,
Davy Van De Moere


Op 12-aug.-2014, om 15:00 heeft <betul.cerit at netgsm.com.tr> <betul.cerit at netgsm.com.tr> het volgende geschreven:

> Hello;
> I am trying to build a prepaid accounting system. I use dialog module's
> start/end event-route. When even_route[dialog:started] triggered, a
> http_query works for the started call. When event_route[dialog:end] triggered , a
> http_query works for call is ended. When http_query works  in
> event_route[dialog:started], i get some CRITICAL ERROR like
> 'Aug 12 12:16:09   /usr/local/sbin/kamailio[10151]: CRITICAL: dialog
> [dlg_timer.c:205]: update_dlg_timer(): Trying to update a bogus dlg
> tl=0x7f7634d925d8 tl->next=(nil) tl->prev=(nil)'
> 'Aug 12 12:16:09   /usr/local/sbin/kamailio[10151]: ERROR: dialog
> [dlg_handlers.c:1263]: dlg_onroute(): failed to update dialog lifetime'
> Http_query works very well. I can get all call information on Web
> Servers but default_time out or other timeout isn't working.
> After i commented out http_query in event_route[dialog:started] , it stopped giving
> ERROR but i realized that dialog cannot uptade dialog hash map .I can see all finished call with "kamctl dialog show". After i closed
> http_query in even_route[dialog:end] , all problems are solved.
> I think a problem occured between http_query and dialog event_routes.It
> cannot control dialog lifetime.Any idea about this problem or suggest an alternative way will be appreciated.My configuration is as follows.
> Best Regards
> Betül.
> #---------------- 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 ; useropkodu ")
> modparam("dialog", "dlg_extra_hdrs", "Hint: Hell Yeah\r\n")
> modparam("dialog", "send_bye", 1)
> #!endif
> route[CHCK_DLG]{
> xlog("L_INFO","DLG:AVP=> :>:$avp(i:77):$avp(op_kodu):$avp(i:69) ");
>                  $dlg_ctx(timeout_bye)=1;
>                  $avp(unique_id)=$sruid;
>                  /* Time out suresi i:10 konusabilecegi sure saniye */
>                  $avp(i:10)=0;
>                  $avp(i:10)=(int)$avp(i:77);
>                  #$avp(i:10)=10;
>                  $dlg_ctx(timeout_route)=33;
>                  $dlg_var(uniqueid)=$avp(unique_id);
>                  $dlg_var(userid)=$avp(userid);
>                  $dlg_var(opkodu)=$avp(op_kodu);
>                  set_dlg_profile("userid","$avp(userid)");
>                  set_dlg_profile("opkodu","$avp(op_kodu)");
> set_dlg_profile("useropkodu","$avp(userid):$avp(op_kodu)");
> if(get_profile_size("useropkodu","$avp(d_user_opkodu)")){
> xlog("L_INFO","Userid_Size:$avp(d_user_opkodu) kk :
> $avp(userid):$avp(op_kodu) ");
> xlog("L_INFO","Userid_Limit:$sht(sayac=>$avp(userid):$avp(op_kodu))");
> if(!($sht(sayac=>$avp(userid):$avp(op_kodu))>$avp(d_user_opkodu))){
> sl_send_reply("403","Kapasite Asildi.");
>                                          exit;
>                          }
>                  }
>                  dlg_manage();
>          return;
> }
> event_route[dialog:start]{
> xlog("L_ALERT","START:CI:$dlg(callid):u_id:$dlg_var(uniqueid):U_id:$dlg_var(userid)
> ");
> xlog("L_ALERT","START:lifetime:$avp(i:10):opkodu:$dlg_var(opkodu):$avp(aranan)"
> );
> #!ifdef WITH_UTILS
> $var(http_res)=http_query("http://bla.com/somestuff.php?userid=$avp(userid)&aranan=$avp(aranan)&callid=$ci&uniqueid=$dlg_var(uniqueid)&lifetime=$avp(i:10)&opkodu=$dlg_var(opkodu)","$var(result)");
>          if($var(http_res)=="200"){
>                  json_get_field("$var(result)","sonuc","$var(snc)");
> json_get_field("$var(result)","yorum","$var(yorum)");
> json_get_field("$var(result)","yorum","$var(debug)");
>                  if($var(snc)!=200){
> xlog("L_ERR","START:CI:$ci:Sonuc:$var(snc):Yorum:$var(yorum):Debug:$var(debug)");
>                  }else{
> xlog("L_INFO","START:CI:$ci:Sonuc:$var(snc)");
>                  }
>          }else{
> xlog("L_ERR","START:CI:$ci:HTTP_RESULT:$var(http_res)");
>          }
> #!endif
> }
> event_route[dialog:end]{
>          xlog("L_ALERT","END
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :");
> xlog("L_ALERT","END:CI:$ci:START_TIME:$dlg(start_ts):NOW:$TS");
>          $var(billsec)=$TS-$dlg(start_ts);
>          xlog("L_ALERT","END:SURE : $var(billsec): u_id:
> $dlg_var(uniqueid):code:$T_reply_code:$DLG_status  ");
> xlog("L_ALERT","END:U_ID:$dlg_var(userid):O_Kodu:$dlg_var(opkodu):");
>          if($var(billsec)<0){
>                  $var(billsec)=$DLG_lifetime;
>                  xlog("L_ERR","START:CI:$ci:Billsec Negatif geldi :
> lifetime alinacak:$DLG_lifetime");
>          }
> #!ifdef WITH_UTILS
> $var(http_res)=http_query("http://bla.com/somestuff.php?uniqueid=$dlg_var(uniqueid)&billsec=$var(billsec)","$var(result)");
>          if($var(http_res)=="200"){
>                  json_get_field("$var(result)","sonuc","$var(snc)");
> json_get_field("$var(result)","yorum","$var(yorum)");
> json_get_field("$var(result)","yorum","$var(debug)");
>                  if($var(snc)!=200){
> xlog("L_ERR","START:CI:$ci:Sonuc:$var(snc):Yorum:$var(yorum):Debug:$var(debug)");
>                  }
>          }else{
> xlog("L_ERR","START:CI:$ci:HTTP_RESULT:$var(http_res)");
>          }
> #!endif
>          xlog("L_ALERT","END
> ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :");
> }
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20140812/fba6675a/attachment.html>


More information about the sr-users mailing list