[OpenSIPS-Users] Dialog vars not being sync'ed from DB to memory

Mariana Arduini marianarduini at gmail.com
Tue May 15 21:03:25 CEST 2012


Hello all,

We need to perform some substitutions in the R-URI and Contact header in
order to have the following flow working as required:

caller > opensips1 > opensips2 > callee

Currently, opensips1 stores "call_id", "caller_tag" and "caller_contact"
Dialog variables using function store_dlg_value() on new INVITES, and
"callee_contact" on 200 OK for the INVITES. Later, for sequential requests,
it compares the from_tag with the caller_tag, accessed using
fetch_dlg_value(), to find out whether it is a request from the caller or
from the callee, and it works. Then I started working on failover for
opensips1, and that's where I'm facing problems. I'm playing with
"db_flush_vals_profiles" new parameter and "dlg_db_sync" new fifo command,
both on Dialog module, in order to have a stand by opensips1 taking over
the dialogs going on in an active opensips1, in case it fails. This is the
test:

1) active opensips is running listening on virtual ip say 10.0.0.1
2) caller sends INVITE to 10.0.0.1, which goes to active opensips
3) active opensips is stopped and it's virtual ip set down; same virtual ip
is set up in stand by opensips and it is started; fifo command dlg_db_sync
is run on stand by opensips
4) caller sends BYE to 10.0.0.1, which goes to stand by opensips

After loose_route(), stand by opensips cannot fetch_dlg_value for
"caller_tag" and the R-URI is set to 0. Then I tried the following, using
only one opensips:

1) caller sends INVITE to opensips
2) fifo command dlg_list_ctx is run and shows all of the variables I stored
3) opensips is restarted and fifo command dlg_db_sync is run
4) fifo command dlg_list_ctx is run again and shows only the dialog info,
not the variables in context

I also
tried get_dialog_info("caller_tag","$var(caller_tag)","call_id","$ci"); and
$dlg_val(), but yet the variables are not found:

22232: DBG:dialog:fetch_dlg_value: looking for <caller_tag>
22232: DBG:dialog:fetch_dlg_value: var NOT found!
22232: ERROR:core:do_assign: no value in right expression
22232: ERROR:core:do_assign: error at line: 134
22232: callid(1-5150 at 192.168.16.154) trying dlg_val(), caller_tag: 0
22232: DBG:core:comp_scriptvar: str 20 : uac1192.168.16.154
22232: DBG:dialog:fetch_dlg_value: looking for <caller_contact>
22232: DBG:dialog:fetch_dlg_value: var NOT found!
22232: ERROR:core:do_assign: no value in right expression
22232: ERROR:core:do_assign: error at line: 146
22232: callid(1-5150 at 192.168.16.154) trying dlg_val(), caller_contact: 0
22232: DBG:tm:t_newtran: transaction on entrance=0xffffffffffffffff
22232: DBG:core:parse_headers: flags=ffffffffffffffff
22232: DBG:core:parse_headers: flags=78
22232: DBG:tm:t_lookup_request: start searching: hash=5130, isACK=0
22232: DBG:tm:matching_3261: RFC3261 transaction matching failed
22232: DBG:tm:t_lookup_request: no transaction found
22232: ERROR:core:parse_uri: uri too short: <0> (1)
22232: ERROR:core:parse_sip_msg_uri: bad uri <0>
22232: DBG:core:set_err_info: ec: 1, el: 3, ei: 'error parsing r-uri'
22232: ERROR:tm:new_t: uri invalid
22232: ERROR:tm:t_newtran: new_t failed

There is no error logs when dlg_db_sync is run. I see in the dialog table a
column called from_tag, is there a way to get its content for a certain
dialog? It seems the functions get_dialog_info(), fetch_dlg_info() and
$dlg_val() only look for variables in the column vars.

Can anyone see other type of solution that does not involve
storing/fetching dialog variables? I could take on that.

I'd really appreciate any help on this.

This is my cfg file:

...
modparam("dialog", "db_url", "postgres://opensips:opensips@opensips_db_host
:5432/opensips")
modparam("dialog", "db_mode", 1)
modparam("dialog", "db_flush_vals_profiles", 1)
...
route {
...
if(is_method("INVITE")) {
 create_dialog();
store_dlg_value("caller_tag", "$ft");
 xlog("L_INFO","Storing caller_tag: $ft");
store_dlg_value("caller_contact", "$ct.fields(uri)");
 xlog("L_INFO","Storing caller_contact: $ct.fields(uri)");
store_dlg_value("call_id", "$ci");
 xlog("L_INFO","Storing call_id: $ci");
                route(1);
        }
...
if (has_totag()) {
 # sequential request withing a dialog should
# take the path determined by record-routing
 if (loose_route()) {

                    $var(caller_tag) = $dlg_val(caller_tag);
                    xlog("L_INFO","trying dlg_val(), caller_tag:
$var(caller_tag)\n");

                    if ($ft == $var(caller_tag)) {
                        $var(callee_contact) = $dlg_val(callee_contact);
                        xlog("L_INFO"," trying dlg_val(), callee_contact:
$var(callee_contact)\n");
                        $ru = $var(callee_contact);
                    } else {
                        $var(caller_contact) = $dlg_val(caller_contact);
                        xlog("L_INFO"," trying dlg_val(), caller_contact:
$var(caller_contact)\n");
                        $ru = $var(caller_contact);
                    }

}
}
        record_route();
        if (!t_relay()) {
                send_reply("500","Internal Error");
        };
        exit;
}
...
route[1] {
# for INVITEs enable some additional helper routes
if (is_method("INVITE")) {
     $rd="opensips2.domain.com";
            $rp="5060";

            # Change Contact header
            if
(subst('/^Contact\s*:\s*("[^"]*")?\s*<?sip:(([^@]*)@)?([^;>]*)((;[^;>]*)*)>?(.*)/Contact:
<sip:plain at my.domain.com\5>\7/ig')) {
                xlog("L_DBG","CONTACT was modified");
            }

    t_on_reply("2");
 }

}
...
onreply_route[2] {

        if(is_present_hf("Contact")) {
            xlog("L_INFO"," Storing callee_contact: $ct.fields(uri)");
            store_dlg_value("callee_contact", "$ct.fields(uri)");
        }

        if
(subst('/^Contact\s*:\s*("[^"]*")?\s*<?sip:([^@]*)@[^;>]*((;[^;>]*)*)>?(.*)/Contact:
<sip:\2 at my.domain.com\3>\5/ig')) {
            xlog("L_DBG","CONTACT was modified");
        }
}
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20120515/f0c1bf3e/attachment.htm>


More information about the Users mailing list