Hi all,

I am a beginner in openser and I really appreciate the help I have been getting from this group. I am setting up an interop with a PSTN gateway with intermittent success. I will try to explain my setup below.

  

                      redirect server
                            /      /
                       2  /      / 3
               1         /      /              4                           5
asterisk ----->  openser (v1.2.1)  -----> pstnGateway ------> PSTN (cell phone)


Calls are generated from asterisk (step 1) with a 3-digit prefix (say, 999) on the ANI to identify a particular group of calls, and sent to openser ( v1.2.1). Openser checks the from_uri; detects the 999 prefix, strips the leading 3 digits and forwards the INVITE to the redirect server (step 2). The redirect server responds with a 301, containing the location of the pstnGateway (step 3). Openser sends an INVITE to address in the 301 to the pstnGateway (step 4) and the call gets completed (step 5)

This setup works intermittently. I sometimes have to restart openser before it works again. When it works, I get a 100 trying message back from the PSTN gateway, but when it fails, I see a number of invites sent from openser to the gateway without getting a 100 trying message back. And the invite times out with a 408 message. After a few seconds, the PSTN number actually rings, but I get dead air.

My configuration is as below:

**********************************************************
loadmodule "uac_redirect.so"
loadmodule "uac.so"

# ----------------- setting module-specific parameters ---------------

# -- mi_fifo params --
modparam("mi_fifo", "fifo_name", "/etc/openser_fifo")
modparam("rr", "enable_full_lr", 1)
modparam("tm", "wt_timer", 30)
modparam("tm", "fr_inv_timer", 120)
modparam("tm", "fr_timer", 2)
modparam("dispatcher", "list_file", "/etc/openser/dispatcher.list")
modparam("dispatcher", "flags", 2)
modparam("dispatcher", "dst_avp", "$avp(i:271)")
modparam("dispatcher", "grp_avp", "$avp(i:272)")
modparam("dispatcher", "cnt_avp", "$avp(i:273)")
modparam("uac","from_restore_mode","auto")

# main routing logic
route {
    if (!mf_process_maxfwd_header("16"))
    {
        xlog("L_INFO", " Reply: 483 - Too Many Hops\n");
        sl_send_reply("483","Too Many Hops");
        exit;
    };
    if ( msg:len > max_len )
    {
        xlog("L_INFO", " Reply: 513 - Message Too Big\n");
        sl_send_reply("513", "Message too big");
        exit;
    };

    if (loose_route())
    {
        record_route();
        t_relay();
        exit;
    };

    record_route();

# Outgoing route route(1);
    route(1);
 
}


# ROUTE 1 - OUTGOING CALLS
route[1] {
        # Check prefix - if the ANI of the tenant starts with 999
        # and the total number of digits is more than 12
        if ((from_uri=~"^sip:999.*")&&$(fu{s.len}) > 12)
        {
            # replace both display and uri
            # Strip out the leading 999 digits before sending it to redirect server
            uac_replace_from("$(fU{s.substr,3,0})","sip:$(fU{s.substr,3,0})@$fd");

            # Check for re-directs
            t_on_failure("4");
            xlog("L_INFO", "RequestUri:[$ru] FromUri:[$fu] forwarding to redirect server...\n");
            ds_select_dst("6", "0"); # forward to redirect server
            t_relay();
            exit;
        }
    }
}


###############################################################################
# Process Replies
###############################################################################
onreply_route[1]
{
    if( status =~ "18[0-9]" )
    {
        # Reset the flag
        t_on_failure("0");
    }
}

#=============================================
# Default redirect handler - PSTN gateway inter-op
#=============================================
failure_route[4]
{
    get_redirects("*");
    t_relay();
}

*********************************************************************************************

Below is a snippet of my logs when the call fails.

-----Call 1
Aug 28 19:53:27  [12103]: [INVITE] [from: asterisk] [calling: 15552121212] [caller: 99915553131313]
Aug 28 19:53:27  [12103]: RequestUri:[sip:15552121212@openser] FromUri:[sip:99915553131313@asterisk] forwarding to redirect server...
Aug 28 19:53:35  [12103]: [ACK] [from: asterisk] [calling: 15552121212] [caller: 99915553131313]
Aug 28 19:53:35  [12103]: ERROR:uac:replace_from: decline FROM replacing in sequential request in auto mode (has TO tag)
Aug 28 19:53:35  [12103]: RequestUri:[sip:15552121212@openser] FromUri:[sip:99915553131313@asterisk ] forwarding to redirect server...
Aug 28 19:53:41  [12107]: [BYE] [from: redirectServer] [calling: 99915553131313] [caller: 15552121212]

-----Call 2
Aug 28 19:53:53  [12105]: [INVITE] [from: asterisk] [calling: 15552121212] [caller: 99915553131313]
Aug 28 19:53:53  [12105]: RequestUri:[sip:15552121212@openser] FromUri:[sip:99915553131313@asterisk] forwarding to redirect server...
Aug 28 19:53:56  [12105]: ERROR:tm:w_t_relay: t_forward_nonack failed


Thanks and many regards,

Tolu