[SR-Users] Dispatcher BYE issue

Muhammad Shahzad shaheryarkh at gmail.com
Wed Nov 26 02:44:18 CET 2014


Don't do loose route in main route block. The WITHINDLG route will take
care of that.

Also you may need to do "handle_ruri_alias" just after loose route in
WITHINDLG route. See below link for more details,

http://www.kamailio.org/docs/modules/4.2.x/modules/nathelper.html#nathelper.f.handle_ruri_alias

something like this,

---
if (loose_route()) {
    if(!isdsturiset()) {
        handle_ruri_alias();
    };

    if (is_method("BYE")) {
...

Thank you.



On Tue, Nov 25, 2014 at 3:49 PM, Ahmed Salem <ahmed.salem4282 at gmail.com>
wrote:

> Hi,
>
> I'm trying to achieve this configuration
>
> phone --> NAT --> kamailio loadbalancer --> kamailio sip/proxy
>             --> kamailio sip/proxy
>
> With the attached configuration I can make calls without any problems
> but when the callee hangs up the call does not end only the caller can
> hang up.
>
> Btw I'm using tcp for signalling.
>
> Any ideas?
> Thanks
>
> #!define FLT_ACC 1
> #!define FLT_ACCMISSED 2
> #!define FLT_ACCFAILED 3
> #!define FLT_NATS 5
>
> #!define FLB_NATB 6
> #!define FLB_NATSIPPING 7
>
>
> mhomed=1
>
> ####### Global Parameters #########
>
> #!ifdef WITH_DEBUG
> debug=4
> log_stderror=yes
> #!else
> debug=2
> log_stderror=no
> #!endif
>
> memdbg=5
> memlog=5
>
> log_facility=LOG_LOCAL0
>
> fork=yes
> children=4
>
> tcp_async=yes
> tcp_connection_lifetime=3605
>
> port=5060
> sip_warning=yes
>
> ####### Modules Section ########
>
> #!ifdef WITH_SRCPATH
> mpath="modules_k:modules"
> #!else
> mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules/"
> #!endif
>
> loadmodule "db_mysql.so"
> loadmodule "mi_fifo.so"
> loadmodule "kex.so"
> loadmodule "tm.so"
> loadmodule "tmx.so"
> loadmodule "sl.so"
> loadmodule "rr.so"
> loadmodule "pv.so"
> loadmodule "maxfwd.so"
> loadmodule "textops.so"
> loadmodule "siputils.so"
> loadmodule "xlog.so"
> loadmodule "sanity.so"
> loadmodule "ctl.so"
> loadmodule "mi_rpc.so"
> loadmodule "acc.so"
> loadmodule "usrloc.so"
> loadmodule "registrar.so"
> loadmodule "dispatcher.so"
> loadmodule "nathelper.so"
> loadmodule "rtpproxy.so"
> loadmodule "path.so"
>
> # ----------------- setting module-specific parameters ---------------
>
>
> # ----- mi_fifo params -----
> modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
>
> # ----- rr params -----
> # add value to ;lr param to cope with most of the UAs
> modparam("rr", "enable_full_lr", 1)
> # do not append from tag to the RR (no need for this script)
> modparam("rr", "append_fromtag", 1)
> modparam("rr", "enable_double_rr", 0)
>
>
> # ----- tm params -----
> modparam("tm", "failure_reply_mode", 3)
> modparam("tm", "fr_timer", 3000)
> modparam("tm", "fr_inv_timer", 120000)
>
> # ----- dispatcher params -----
> modparam("dispatcher", "db_url",
> "mysql://kamailio:kamailiorw@localhost/kamailio")
> modparam("dispatcher", "table_name", "dispatcher")
> modparam("dispatcher", "flags", 2)
> #modparam("dispatcher", "force_dst", 1)
> modparam("dispatcher", "setid_col", "setid")
> modparam("dispatcher", "destination_col", "destination")
> modparam("dispatcher", "flags_col", "flags")
> modparam("dispatcher", "priority_col", "priority")
> modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
> modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
> modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
>
>
> modparam("path", "use_received", 1)
>
> modparam("registrar", "use_path", 1)
> modparam("registrar", "path_mode", 0)
> modparam("registrar", "path_use_received", 1)
>
> modparam("nathelper", "natping_interval", 30)
> modparam("nathelper", "ping_nated_only", 1)
> modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
> modparam("nathelper", "sipping_from", "sip:pinger at kamailio.org")
>
> # params needed for NAT traversal in other modules
> modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
> modparam("usrloc", "nat_bflag", FLB_NATB)
>
> ####### Routing Logic ########
>
>
> # main request routing logic
>
> request_route {
> xlog("L_NOTICE", "*** loose routing enforced before: $rm, $ru, $si,
> $du\n");
> # per request initial checks
>   route(REQINIT);
>  loose_route();
>  # handle requests within SIP dialogs
> route(WITHINDLG);
>
> ### only initial requests (no To tag)
>
> # CANCEL processing
> if (is_method("CANCEL"))
> {
> if (t_check_trans())
> t_relay();
> exit;
> }
>
> t_check_trans();
>
> # record routing for dialog forming requests (in case they are routed)
> # - remove preloaded route headers
> #remove_hf("Route");
> if (is_method("INVITE")){
> record_route();
> }
>  if(is_method("REGISTER")){
> add_path_received();
> fix_nated_register();
> }
> else{
> add_contact_alias();
> }
>
> # dispatch destinations
> route(DISPATCH);
>
> route(RELAY);
> }
>
>
> route[RELAY] {
> if (!t_relay()) {
> sl_reply_error();
> }
> exit;
> }
>
> # Per SIP request initial checks
> route[REQINIT] {
> if (!mf_process_maxfwd_header("10")) {
> sl_send_reply("483","Too Many Hops");
> exit;
> }
>
> if(!sanity_check("1511", "7"))
> {
> xlog("L_NOTICE", "*** loose routing enforced before: $rm, $ru, $si,
> $du\n");
> xlog("Malformed SIP message from $si:$sp\n");
> exit;
> }
> }
>
> # 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()) {
> if (is_method("BYE")) {
> setflag(1); # do accounting ...
> setflag(3); # ... even if the transaction fails
> }
> route(RELAY);
> } else {
> if (is_method("SUBSCRIBE") && uri == myself) {
> # in-dialog subscribe requests
> #route(PRESENCE);
> exit;
> }
> if ( is_method("ACK") ) {
>  if ( t_check_trans() ) {
> # non loose-route, but stateful ACK;
> # must be ACK after a 487 or e.g. 404 from upstream server
> t_relay();
> exit;
> } else {
> # ACK without matching transaction ... ignore and discard.
> exit;
> }
> }
> sl_send_reply("404","Not here");
> }
> exit;
> }
> }
>
> # Dispatch requests
> route[DISPATCH] {
> # round robin dispatching on gateways group '1'
> if(!ds_select_domain("1", "0"))
> {
> send_reply("404", "No destination");
> exit;
> }
> xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
> t_on_failure("RTF_DISPATCH");
> return;
> }
>
> # Sample failure route
> failure_route[RTF_DISPATCH] {
> if (t_is_canceled()) {
> exit;
> }
> # next DST - only for 500 or local timeout
> if (t_check_status("500")
> or (t_branch_timeout() and !t_branch_replied()))
> {
> if(ds_next_domain())
> {
> xlog("L_NOTICE", "going to next dst\n");
> t_on_failure("RTF_DISPATCH");
> route(RELAY);
> exit;
> }
> }
> }
>
>
>
> _______________________________________________
> 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/20141126/4c053dc0/attachment.html>


More information about the sr-users mailing list