[OpenSIPS-Users] ul_publish: failed to send publish

Michele Pinassi michele.pinassi at unisi.it
Fri Nov 14 10:41:43 CET 2014


Hi all,

on each REGISTER i have a row in "location" table, set by Register
module (as seen on docs). After few minutes, some rosw was deleted and
my log show:

ERROR:pua_usrloc:ul_publish: failed to send publish

Any hints how to fix this issue ?

Here's my config, purged from unnecessary lines:

#### PRESENCE modules
loadmodule "presence.so"
loadmodule "presence_mwi.so"
loadmodule "presence_callinfo.so"
loadmodule "presence_dialoginfo.so"

modparam("presence", "server_address", "sip:172.20.1.2:5060")
modparam("presence", "notify_offline_body", 1)
modparam("presence", "fallback2db", 1)
modparam("presence", "clean_period",  30)

####  PUA module
loadmodule "pua.so"
loadmodule "pua_dialoginfo.so"
loadmodule "pua_usrloc.so"
loadmodule "pua_bla.so"

modparam("pua_dialoginfo", "presence_server", "sip:172.20.1.2:5060")

modparam("pua_usrloc", "default_domain", "voip.unisi.it")

modparam("pua_bla", "header_name", "Sender")
modparam("pua_bla", "default_domain", "voip.unisi.it")
modparam("pua_bla", "server_address", "sip:172.20.1.2:5060")
modparam("pua_bla", "presence_server", "sip:172.20.1.2:5060")

# main request routing logic

route {
    force_rport();
   
    if (is_method("INVITE")) {
         # Bisogna usare RTPproxy per le comunicazioni ?
            if (!get_source_group("$var(group)") ) {
        $var(group) = 3;
        }
       
        # User net group:
        # 1 = Internal VoIP subnet 172.20
        # 2 = External VoIP subnet but inside Unisi context 172.16 | 10.0.0
        # 3 = Outside/foreign (not allowed)
       
        xlog("L_INFO", "User net group is $var(group)
[$fd/$fu/$rd/$ru/$si]\n");
    }

    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
        exit;
    }
   
    # Verifica che l'IP provenga da una rete abilitata (address table)
    if (!check_address("0","$si","$sp","$proto")) {
        xlog("L_INFO","IP $si Forbidden");
        sl_send_reply("403", "Forbidden");
    }

    if (has_totag()) {
        # sequential request withing a dialog should
        # take the path determined by record-routing
        if (loose_route()) {
           
            # validate the sequential request against dialog
            if ( $DLG_status!=NULL && !validate_dialog() ) {
                xlog("In-Dialog $rm from $si (callid=$ci) is not valid
according to dialog\n");
                ## exit;
            }
           
            if (is_method("INVITE")) {
                # even if in most of the cases is useless, do RR for
                # re-INVITEs alos, as some buggy clients do change route set
                # during the dialog.
                record_route();
            }

            if (check_route_param("nat=yes"))
                setflag(NAT);

            # route it out to whatever destination was set by loose_route()
            # in $du (destination URI).
            route(relay);
        } else {
            if (is_method("SUBSCRIBE") && $rd == "127.0.0.1:5060") { #
CUSTOMIZE ME
                # in-dialog subscribe requests
                route(handle_presence);
                exit;
            }
            if ( is_method("ACK") ) {
                if ( t_check_trans() ) {
                    # non loose-route, but stateful ACK; must be an 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;
    }

    # CANCEL processing
    if (is_method("CANCEL"))
    {
        if (t_check_trans())
            t_relay();
        exit;
    }

    t_check_trans();

    if ( !(is_method("REGISTER")  || is_from_gw() ) ) {
        if (is_from_local()) {
            if (!proxy_authorize("", "subscriber")) {
                proxy_challenge("", "0");
                exit;
            }
            if (!db_check_from()) {
                sl_send_reply("403","Forbidden auth ID");
                exit;
            }
       
            consume_credentials();
        } else {
            if (!is_uri_host_local()) {
                send_reply("403","Rely forbidden");
                exit;
            }
        }

    }

    # preloaded route checking
    if (loose_route()) {
        xlog("L_ERR", "Attempt to route with preloaded Route's
[$fu/$tu/$ru/$ci]");
        if (!is_method("ACK"))
            sl_send_reply("403","Preload Route denied");
        exit;
    }

    # record routing
    if (!is_method("REGISTER|MESSAGE"))
        record_route();

    # account only INVITEs
    if (is_method("INVITE")) {
        # create dialog with timeout
        if ( !create_dialog() ) {
            send_reply("500","Internal Server Error");
            exit;
        }
        dialoginfo_set();
    }

   
    if (!is_uri_host_local()) {
        append_hf("P-hint: outbound\r\n");
       
        route(relay);
    }

    ### PUBLISH and NOTIFY

    # For MWI...
    if(is_method("SUBSCRIBE") && search("^Event: message-summary")) {
        # if there is no R-URI username, grab From URI
            if(!uri=~"sip:.+@") { # add From username as R-URI username
                avp_pushto("$ruri/username","$fU");
            }
            # fix some broken subscriptions
            if(!search("^Accept: application/simple-message-summary"))
            append_hf("Accept: application/simple-message-summary\r\n");
           
            setdsturi("sip:172.20.1.5:5060");
            t_relay();
            exit;
        }

    # ...for anything else...
    if(is_method("PUBLISH|SUBSCRIBE")) {
        route(handle_presence);
    }

    ### REGISTER
    if (is_method("REGISTER")) {
        # authenticate the REGISTER requests
        if (!www_authorize("", "subscriber"))
        {
            www_challenge("", "0");
            exit;
        }
       
        if (!db_check_to())
        {
            sl_send_reply("403","Forbidden auth ID");
            exit;
        } else {
            xlog("L_INFO", "Registration SUCCESS $fu\n");
        }
       
        if ( 0 ) setflag(TCP_PERSISTENT);
           
        # Save location
        if (!save("location"))
            sl_reply_error();

        exit;
    }

    # apply DB based aliases
    alias_db_lookup("dbaliases");
   
    if ($rU==NULL) {
        # request with no Username in RURI
        sl_send_reply("484","Address Incomplete");
        exit;
    }
   
    # User set BLIND CALL FORWARD ?
    if(avp_db_load("$ru","$avp(callfwd)")) {
        $ru = $avp(callfwd);
        xlog("L_INFO", "Inbound call: DID found in dbaliases.  Account
ID is $rU\n");
    }

    if(!dp_translate("0", "$rU/$rU", "$avp(dest)")) {
        xlog("L_ERR","420 - Invalid destination $rU\n");
        sl_send_reply("420","Invalid Destination");
        exit;
    }

    xlog("Context for $rU is $avp(dest)\n");
   
    # do lookup with method filtering
    if (!lookup("location","m")) {
        switch ($retcode) {
            case -1: # Note here: check for blacklist numbers
                if (!check_blacklist("globalblacklist")) {
                    sl_send_reply("403", "Forbidden - Call not allowed");
                    exit;
                }

               
                # Check for user ACLs
                if($rU=~"^\0") {
                    if(!db_is_user_in("Credentials","extern")) {
                    xlog("L_INFO","403 - Forbidden [from $fu to $ru]\n");
                    sl_send_reply("403", "Forbidden - External calls not
allowed from this account");
                    exit;
                    }
                }

                # Check for user blacklist
                $avp(80) = $rU;
                if (!check_user_blacklist("$avp(80)", "$avp(82)")) {
                    sl_send_reply("403", "Forbidden - User not allowed
to call this number");
                    exit;
                }
               
                if (db_does_uri_exist()) {
                    xlog("L_ERR", "Number $rU not registered\n");
                    prefix("VMR_");
                    route(mediabox);
                }
               
                if($avp(dest)=="external") {
                    route(pstn);
                }
               
                    if($avp(dest)=="media") {
                        route(mediabox);
                }
               
                if($avp(dest)=="voip") {
                    xlog("L_ERR", "404 - Number $rU not found\n");
                    prefix("FAIL_");
                    route(mediabox);
                }
                exit;
            case -3: # internal error
                t_newtran();
                t_reply("404", "Not Found");
                exit;
            case -2: # method not supported
                sl_send_reply("405", "Method Not Allowed");
                exit;
        }
    }
   
    if (isbflagset(NAT)) setflag(NAT);

    route(relay);
}


# RELAY
route[relay] {
    # for INVITEs enable some additional helper routes
    if (is_method("INVITE")) {
        xlog("L_INFO","Route RELAY on INVITE [$fd/$fu/$rd/$ru/$si/]\n");

        dialoginfo_set();

            t_on_branch("per_branch_ops");
        t_on_failure("missed_call");
    }

    if (isflagset(NAT)) {
            add_rr_param(";nat=yes");
    }

    if (!t_relay()) {
            send_reply("500","Internal Error");
    }
    exit;
}


# Presence route

route[handle_presence] {
    xlog("L_INFO","Route PRESENCE [$fd/$fu/$rd/$ru/$si/]\n");
    if(!t_newtran()){
        sl_reply_error();
        exit;
    }

    if (is_method("PUBLISH")) {
        if($hdr(Sender)!= NULL)
            handle_publish("$hdr(Sender)");
    else
        handle_publish();
    }
   
    if (is_method("SUBSCRIBE")) {
    handle_subscribe();
    }
    exit;
}

branch_route[per_branch_ops] {
    xlog("L_INFO","Route NEW BRANCH [$fd/$fu/$rd/$ru/$si/]\n");
}

failure_route[missed_call] {
    xlog("L_INFO","Route MISSED CALL [$fd/$fu/$rd/$ru/$si/]\n");
    if (t_was_cancelled()) {
        exit;
    }

    # User set CALL FORWARD ON BUSY ?
    if (t_check_status("486")) {
        revert_uri();
        if(avp_db_load("$ru","$avp(fwdbusy)")) {
        $ru = $avp(fwdbusy);
        xlog("L_INFO","User forward on BUSY to $ru\n");
        } else {
        # Forward call with BUSY to Asterisk
        prefix("BUSY_");
        rewritehostport("172.20.1.5:5060");
        }
        t_relay();
    }
   
    # if the failure code is "408 - timeout" or "480 - unanswered"
    if (t_check_status("408|480")) {
        revert_uri();
        if(avp_db_load("$ru","$avp(fwdnoans)")) {
        $ru = $avp(fwdnoans);
        xlog("L_INFO","User forward on TIMEOUT/NOANSWER to $ru\n");
        } else {
        prefix("VMR_");
           
            rewritehostport("172.20.1.5:5060");
        }
        t_relay();
    }
   
    # For other...
    if (t_check_status("5[0-9][0-9]")) {
        revert_uri();
        prefix("FAILURE_");
        rewritehostport("172.20.1.5:5060");
        t_relay();
    }
}

failure_route[next_gw] {
    if (use_next_gw()) {
    t_relay();
    exit;
    }
}

route[mediabox] {
    xlog("L_INFO","Route MEDIABOX [$fd/$fu/$rd/$ru/$si/]\n");

    if(route_to_carrier("mediabox")) {
    t_on_failure("next_gw");
    t_relay();
    exit;
    }

}


route[pstn] {
    xlog("L_INFO","Route to PSTN [$fd/$fu/$rd/$ru/$si/]\n");
   
    if(route_to_carrier("pstn")) {
    t_on_failure("next_gw");
    t_relay();
    exit;
    }

}

-- 
Michele Pinassi
Responsabile Telefonia di Ateneo
Servizio Reti, Sistemi e Sicurezza Informatica - Università degli Studi di Siena
tel: 0577.(23)2169 - fax: 0577.(23)2053

Per trovare una soluzione rapida ai tuoi problemi tecnici
consulta le FAQ di Ateneo, http://www.faq.unisi.it 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.opensips.org/pipermail/users/attachments/20141114/5635e41f/attachment.pgp>


More information about the Users mailing list