<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<tt>Hi Daren,<br>
<br>
Yes, correct, all the onreply_route and failure_route are 100%
stateful, provided by the tm module (transaction module). So,
whenever you are in one of those routes, you should do (if
permitted) only stateful signaling and not stateless, otherwise
you will get unexpected behaviors from OpenSIPS and the TM engine
is not aware of your stateless ops (from script).<br>
<br>
In the stateful blocks, use t_reply() or send_reply() (which is
actually a wrapper over t_relay() + sl_send_reply()). But going
back to the failure of t_relay() - the function will automatically
try to send back a stateful reply and it will report error to
script only if even this replying failed - so makes no sense to
try to send from script , again, a negative reply (the t_relay()
already tried it and failed to do it).<br>
<br>
Best regards,<br>
</tt>
<pre class="moz-signature" cols="72">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS Summit, Amsterdam, May 2020
<a class="moz-txt-link-freetext" href="https://www.opensips.org/events/Summit-2020Amsterdam/">https://www.opensips.org/events/Summit-2020Amsterdam/</a>
OpenSIPS Bootcamp, Miami, March 2020
<a class="moz-txt-link-freetext" href="https://opensips.org/training/OpenSIPS_Bootcamp_2020/">https://opensips.org/training/OpenSIPS_Bootcamp_2020/</a>
</pre>
<div class="moz-cite-prefix">On 1/7/20 1:27 AM, Daren FERREIRA
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:8FAA9404-6B51-4A72-940C-A1178BA4FADC@hotmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hi Bogdan,
<div class=""><br class="">
</div>
<div class="">I have no idea on real changes between 2.3 and 3.0
but it seems that there is much more script sanity checks (and
that’s great) that now blocks (erroneous) things that was not
blocked before…</div>
<div class="">For example, that’s the reason why i had to replace
sl_send_reply() by send_reply().</div>
<div class="">But in my case, i’m already in a failure_route.</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">failure_route</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#2fb41d" class="">[GW_FAILOVER]</span><span
style="font-variant-ligatures: no-common-ligatures" class="">
{</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
route(CONTROLS)</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo; min-height: 13px;"
class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""></span><br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
if (t_was_cancelled()) {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
exit</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
}</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
do_accounting("db","failed")</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
$acc_extra(identity)=</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#b42419" class="">$hdr(P-Asserted-Identity)</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
$acc_extra(src)=</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#b42419" class="">$fU</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
$acc_extra(dst)=</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#b42419" class="">$tU</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
$acc_extra(src_ip) =</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#b42419" class=""> $si</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">; # source IP of the request</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo; min-height: 13px;"
class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""></span><br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo; color: rgb(64, 11,
217);" class=""><span style="font-variant-ligatures:
no-common-ligatures; color: #000000" class=""> </span><span
style="font-variant-ligatures: no-common-ligatures" class="">#
failure detection with redirect to next available trunk</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
if (t_check_status("(408)|(</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#2fb41d" class="">[56][0-9][0-9]</span><span
style="font-variant-ligatures: no-common-ligatures" class="">)"))
{</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
xlog("L_INFO","Failed trunk $rd/$du detected
\n")</span><span style="font-variant-ligatures:
no-common-ligatures; color: #400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo; min-height: 13px;"
class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""></span><br class="">
</div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
if ( ds_next_dst() ) {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures;"
class=""><font class="" color="#400bd9">
</font>t_on_branch("CLEANING")</span><span
style="font-variant-ligatures: no-common-ligatures;"
class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
t_on_failure("GW_FAILOVER")</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
route(RELAY)</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class=""><span style="caret-color: rgb(0, 0, 0);
color: rgb(0, 0, 0);" class="">#this block is not usable
there</span></span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
if (!t_relay()) {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures;"
class=""><span class="Apple-tab-span" style="white-space:pre"> </span>sl_reply_error();</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
}</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
exit</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
}</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
send_reply(500,"All GW are down")</span><span
style="font-variant-ligatures: no-common-ligatures; color:
#400bd9" class="">;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
}</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">
<div style="font-family: Helvetica; font-size: 12px;"
class=""><span style="font-variant-ligatures:
no-common-ligatures;" class="">So do you think
activating the failure_route inside the failure_route is
enough to manage the eventual t_relay failures? (and by
the way, is it safe to activate failure_routes inside
failure_routes).</span></div>
<div class=""><br class="">
</div>
</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">Reading your other posts
(about 408 failover) makes me better understand the opensips
internal (i think so).</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">If i well understand, a
failure_route is forcibly stateful, so it is not logical to
send stateless replies inside a stateful block.</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">On the opposite side i
actually no idea how to send errors replies inside stateful
blocks (maybe that’s internally managed - there is my
limit).</span></div>
<div class=""><br class="">
</div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">I hope this is better now to
understand my problem.</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""><br class="">
</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">Thank you</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""><br class="">
</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">Regards</span></div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">Le 6 janv. 2020 à 18:41, Bogdan-Andrei Iancu
<<a href="mailto:bogdan@opensips.org" class=""
moz-do-not-send="true">bogdan@opensips.org</a>> a
écrit :</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi Daren,<br class="">
<br class="">
I do not remember to have any changes between 2.3 and
3.0 when comes to the sl_send_reply() usage - maybe you
can be more explicit on the differences you see between
the versions.<br class="">
<br class="">
Now, one using handling the failure of `t_relay()` - if
the function has some internal failure in sending out
the request, it will automatically send back a negative
reply and return success to script. The failure
indication is returned to the script ONLY if the both
sending the request AND the negative reply ops failed.<br
class="">
The sending of the negative reply is done in stateful
mode, so this is the explanation of sl_reply_error() you
see in examples - it will try to report back a reply in
a stateless mode (in a lighter way, with a higher
probability of success than the stateful attempt).<br
class="">
Why not doing this in failure route? as in failure route
you are already in stateful mode, so there are almost 0
chances to get a failure indication from t_relay().<br
class="">
<br class="">
As a note, see the 0x02 flag for t_relay() - <a
href="https://opensips.org/html/docs/modules/3.0.x/tm.html#func_t_relay"
class="" moz-do-not-send="true">https://opensips.org/html/docs/modules/3.0.x/tm.html#func_t_relay</a><br
class="">
<br class="">
Best Regards,<br class="">
<br class="">
Bogdan-Andrei Iancu<br class="">
<br class="">
OpenSIPS Founder and Developer<br class="">
<a href="https://www.opensips-solutions.com" class=""
moz-do-not-send="true">https://www.opensips-solutions.com</a><br
class="">
OpenSIPS Summit, Amsterdam, May 2020<br class="">
<a
href="https://www.opensips.org/events/Summit-2020Amsterdam/"
class="" moz-do-not-send="true">https://www.opensips.org/events/Summit-2020Amsterdam/</a><br
class="">
OpenSIPS Bootcamp, Miami, March 2020<br class="">
<a
href="https://opensips.org/training/OpenSIPS_Bootcamp_2020/"
class="" moz-do-not-send="true">https://opensips.org/training/OpenSIPS_Bootcamp_2020/</a><br
class="">
<br class="">
On 12/15/19 5:11 PM, Daren FERREIRA wrote:<br class="">
<blockquote type="cite" class="">Hello,<br class="">
<br class="">
I’ve been using my configuration script for a while
without problems on 2.3.x releases, but, with 3.0.x
some errors are coming.<br class="">
Syntax changes are not a problem, as fortunately
changes are well documented on the wikis :)<br
class="">
<br class="">
My problem is relative to replies (sl_send_reply and
sl_reply_error) and the places where we’re allowed to
use them.<br class="">
For sl_send_reply, send_reply alternative has solved
my problem, but that’s not as easy for sl_reply_error.<br
class="">
<br class="">
In every documentation, examples or forums i read, we
use to do<br class="">
<br class="">
if (!t_relay()) {<br class="">
sl_reply_error();<br class="">
}<br class="">
<br class="">
In order to send an error in case of any problem with
t_relay.<br class="">
<br class="">
But sl_reply_error is forbidden in failure routes, so,
should we consider there will never have any problems
with t_relay in failure routes?<br class="">
<br class="">
In my case i use dispatcher, and, in case of failure,
i try to find another destination, and relay messages
to it, until the call succeed…<br class="">
If the first try fails, it triggers a failure route
where i’m no more able to send an error if the t_relay
fails…<br class="">
<br class="">
So is it safe not to check anymore the t_relay return
on failure routes?<br class="">
If not, is there any alternatives? I think about using
send_reply instead of sl_reply_error, but with what
arguments? $err.rcode and $err.rreason ?<br class="">
<br class="">
Thank you for your help and comments.<br class="">
<br class="">
Regards<br class="">
_______________________________________________<br
class="">
Users mailing list<br class="">
<a href="mailto:Users@lists.opensips.org" class=""
moz-do-not-send="true">Users@lists.opensips.org</a><br
class="">
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br class="">
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</blockquote>
<br>
</body>
</html>