Hello all,<div><br></div><div>We need to perform some substitutions in the R-URI and Contact header in order to have the following flow working as required:</div><div><br></div><div>caller &gt; opensips1 &gt; opensips2 &gt; callee</div>

<div><br></div><div>Currently, opensips1 stores &quot;call_id&quot;, &quot;caller_tag&quot; and &quot;caller_contact&quot; Dialog variables <meta http-equiv="content-type" content="text/html; charset=utf-8">using function store_dlg_value() on new INVITES, and &quot;callee_contact&quot; 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&#39;s where I&#39;m facing problems. I&#39;m playing with &quot;db_flush_vals_profiles&quot; new parameter and &quot;dlg_db_sync&quot; 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:<div>

<br></div><div>1) active opensips is running listening on virtual ip say 10.0.0.1</div><div>2) caller sends INVITE to 10.0.0.1, which goes to active opensips</div><div>3) active opensips is stopped and it&#39;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</div>

<div>4) caller sends BYE to 10.0.0.1, which goes to stand by opensips</div><div><br></div><div>After loose_route(), stand by opensips cannot fetch_dlg_value for &quot;caller_tag&quot; and the R-URI is set to 0. Then I tried the following, using only one opensips:</div>

<div><br></div><div>1) caller sends INVITE to opensips</div><div>2) fifo command dlg_list_ctx is run and shows all of the variables I stored</div><div>3) opensips is restarted and fifo command dlg_db_sync is run</div><div>

4) fifo command dlg_list_ctx is run again and shows only the dialog info, not the variables in context</div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>

<br></div><div>I also tried get_dialog_info(&quot;caller_tag&quot;,&quot;$var(caller_tag)&quot;,&quot;call_id&quot;,&quot;$ci&quot;); and $dlg_val(), but yet the variables are not found:</div><div><br></div><div><div><div>

22232: DBG:dialog:fetch_dlg_value: looking for &lt;caller_tag&gt;</div><div>22232: DBG:dialog:fetch_dlg_value: var NOT found!</div><div>22232: ERROR:core:do_assign: no value in right expression</div><div>22232: ERROR:core:do_assign: error at line: 134</div>

<div>22232: callid(<a href="mailto:1-5150@192.168.16.154">1-5150@192.168.16.154</a>) trying dlg_val(), caller_tag: 0</div><div>22232: DBG:core:comp_scriptvar: str 20 : uac1192.168.16.154</div><div>22232: DBG:dialog:fetch_dlg_value: looking for &lt;caller_contact&gt;</div>

<div>22232: DBG:dialog:fetch_dlg_value: var NOT found!</div><div>22232: ERROR:core:do_assign: no value in right expression</div><div>22232: ERROR:core:do_assign: error at line: 146</div><div>22232: callid(<a href="mailto:1-5150@192.168.16.154">1-5150@192.168.16.154</a>) trying dlg_val(), caller_contact: 0</div>

<div>22232: DBG:tm:t_newtran: transaction on entrance=0xffffffffffffffff</div><div>22232: DBG:core:parse_headers: flags=ffffffffffffffff</div><div>22232: DBG:core:parse_headers: flags=78</div><div>22232: DBG:tm:t_lookup_request: start searching: hash=5130, isACK=0</div>

<div>22232: DBG:tm:matching_3261: RFC3261 transaction matching failed</div><div>22232: DBG:tm:t_lookup_request: no transaction found</div><div>22232: ERROR:core:parse_uri: uri too short: &lt;0&gt; (1)</div><div>22232: ERROR:core:parse_sip_msg_uri: bad uri &lt;0&gt;</div>

<div>22232: DBG:core:set_err_info: ec: 1, el: 3, ei: &#39;error parsing r-uri&#39;</div><div>22232: ERROR:tm:new_t: uri invalid</div><div>22232: ERROR:tm:t_newtran: new_t failed</div></div></div><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div>

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.</div>

<div><br></div><div>Can anyone see other type of solution that does not involve storing/fetching dialog variables? I could take on that.</div><div><br></div><div>I&#39;d really appreciate any help on this.</div><div><br>
</div>
</div><div><meta http-equiv="content-type" content="text/html; charset=utf-8">This is my cfg file:<div><br></div><div>...</div><div><div>modparam(&quot;dialog&quot;, &quot;db_url&quot;, &quot;postgres://opensips:opensips@opensips_db_host:5432/opensips&quot;)</div>

<div>modparam(&quot;dialog&quot;, &quot;db_mode&quot;, 1)</div><div>modparam(&quot;dialog&quot;, &quot;db_flush_vals_profiles&quot;, 1)</div></div><div>...</div><div><div>route {   </div><div>...</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if(is_method(&quot;INVITE&quot;)) {</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span>create_dialog();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>store_dlg_value(&quot;caller_tag&quot;, &quot;$ft&quot;);</div><div>

<span class="Apple-tab-span" style="white-space:pre">                </span>xlog(&quot;L_INFO&quot;,&quot;Storing caller_tag: $ft&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>store_dlg_value(&quot;caller_contact&quot;, &quot;$ct.fields(uri)&quot;);</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span>xlog(&quot;L_INFO&quot;,&quot;Storing caller_contact: $ct.fields(uri)&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>store_dlg_value(&quot;call_id&quot;, &quot;$ci&quot;);</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span>xlog(&quot;L_INFO&quot;,&quot;Storing call_id: $ci&quot;);</div><div>                route(1);</div><div>        }</div></div><div>...</div><div><div>if (has_totag()) {</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span># sequential request withing a dialog should</div><div><span class="Apple-tab-span" style="white-space:pre">                </span># take the path determined by record-routing</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span>if (loose_route()) {</div><div><br></div><div>                    $var(caller_tag) = $dlg_val(caller_tag);</div><div>                    xlog(&quot;L_INFO&quot;,&quot;trying dlg_val(), caller_tag: $var(caller_tag)\n&quot;);</div>

<div><br></div><div>                    if ($ft == $var(caller_tag)) {</div><div>                        $var(callee_contact) = $dlg_val(callee_contact);</div><div>                        xlog(&quot;L_INFO&quot;,&quot; trying dlg_val(), callee_contact: $var(callee_contact)\n&quot;);</div>

<div>                        $ru = $var(callee_contact);</div><div>                    } else {</div><div>                        $var(caller_contact) = $dlg_val(caller_contact);</div><div>                        xlog(&quot;L_INFO&quot;,&quot; trying dlg_val(), caller_contact: $var(caller_contact)\n&quot;);</div>

<div>                        $ru = $var(caller_contact);</div><div>                    }</div><div>            </div><div><span class="Apple-tab-span" style="white-space:pre">                </span>} </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div>

<div>        record_route();</div><div>        if (!t_relay()) {</div><div>                send_reply(&quot;500&quot;,&quot;Internal Error&quot;);</div><div>        };</div><div>        exit;</div><div>}</div><div>...</div>

<div>route[1] {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span># for INVITEs enable some additional helper routes</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (is_method(&quot;INVITE&quot;)) {</div>

<div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    $rd=&quot;<a href="http://opensips2.domain.com">opensips2.domain.com</a>&quot;;</div>

<div>            $rp=&quot;5060&quot;;<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><br></div><div>            # Change Contact header</div><div>            if (subst(&#39;/^Contact\s*:\s*(&quot;[^&quot;]*&quot;)?\s*&lt;?sip:(([^@]*)@)?([^;&gt;]*)((;[^;&gt;]*)*)&gt;?(.*)/Contact: &lt;<a href="mailto:sip%3Aplain@my.domain.com">sip:plain@my.domain.com</a>\5&gt;\7/ig&#39;)) {</div>

<div>                xlog(&quot;L_DBG&quot;,&quot;CONTACT was modified&quot;);</div><div>            }</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    t_on_reply(&quot;2&quot;);</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div>}</div><div>...</div><div>onreply_route[2] {</div><div><br></div><div>        if(is_present_hf(&quot;Contact&quot;)) {</div><div>

            xlog(&quot;L_INFO&quot;,&quot; Storing callee_contact: $ct.fields(uri)&quot;);</div><div>            store_dlg_value(&quot;callee_contact&quot;, &quot;$ct.fields(uri)&quot;);</div><div>        }</div><div><br>

</div><div>        if (subst(&#39;/^Contact\s*:\s*(&quot;[^&quot;]*&quot;)?\s*&lt;?sip:([^@]*)@[^;&gt;]*((;[^;&gt;]*)*)&gt;?(.*)/Contact: &lt;sip:\<a href="mailto:2@my.domain.com">2@my.domain.com</a>\3&gt;\5/ig&#39;)) {</div>

<div>            xlog(&quot;L_DBG&quot;,&quot;CONTACT was modified&quot;);</div><div>        } </div><div>}</div></div><div><div>...</div></div></div><div><br></div>