<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">The previous solution won't work
because you can't call t_was_cancelled() in the main route... You
should:<br>
<br>
1) set $T_fr_timeout and $T_fr_inv_timeout to 1<br>
2) t_on_failure(...) [1]<br>
3) t_relay() to a bogus gateway [2]<br>
4) catch the 408 timeout in the failure route. Using an $avp
counter, go back to step 1) until 30 tries have been done. In this
failure route, you may now also use t_was_cancelled().<br>
<br>
[1] : <a class="moz-txt-link-freetext" href="http://www.opensips.org/Documentation/Script-Routes-2-1#toc3">http://www.opensips.org/Documentation/Script-Routes-2-1#toc3</a><br>
[2] :
<a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/2.1.x/tm.html#trelay-1">http://www.opensips.org/html/docs/modules/2.1.x/tm.html#trelay-1</a><br>
<br>
On 03.03.2015 14:57, Liviu Chircu wrote:<br>
</div>
<blockquote cite="mid:54F5AFBC.1000200@opensips.org" type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix"><tt>Hello merlin,<br>
<br>
First of all, from a user's perspective, a Post-Dial Delay of
up to 30 seconds should be quite annoying. Your SIP logic will
also increase the amount of traffic received by your platform,
due to lots of retransmissions for all failed calls.<br>
<br>
That being said, here is what you should add in order to make
it work:<br>
<br>
t_newtran();<br>
...<br>
while (...) {<br>
if (t_was_cancelled()) {<br>
t_reply("487", "Request Cancelled");<br>
exit;<br>
}<br>
...<br>
}<br>
<br>
Best regards,<br>
</tt>
<pre class="moz-signature" cols="72">Liviu Chircu
OpenSIPS Developer
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
On 03.03.2015 10:45, <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:merlin.li@tsingch.com">merlin.li@tsingch.com</a>
wrote:<br>
</div>
<blockquote cite="mid:2015030316451426487717@tsingch.com"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }div.foxdiv20150303164323968249 { }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style>
<div><span></span>Hi,</div>
<div><br>
</div>
<div>Or is there a way i can break the while loop in the route
block when i receive the CANCEL request?</div>
<div><br>
</div>
<hr style="width: 210px; height: 1px;" size="1" align="left"
color="#b5c4df">
<div><span>
<div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE:
10pt">
<div><a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:merlin.li@tsingch.com">merlin.li@tsingch.com</a></div>
</div>
</span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px;
margin-left: 0.5em;">
<div> </div>
<div style="border:none;border-top:solid #B5C4DF
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px;
FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000;
BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP:
8px">
<div><b>From:</b> <a moz-do-not-send="true"
href="mailto:merlin.li@tsingch.com">merlin.li@tsingch.com</a></div>
<div><b>Date:</b> 2015-03-03 16:14</div>
<div><b>To:</b> <a moz-do-not-send="true"
href="mailto:users@lists.opensips.org">users</a></div>
<div><b>Subject:</b> how to cancel an INVITE before the
callee receive it?</div>
</div>
</div>
<div>
<div class="FoxDiv20150303164323968249">
<div><span></span>Hi all,</div>
<div><br>
</div>
<div>Let me describe my scenario first.</div>
<div><br>
</div>
<div>if the callee is not online, opensips will wait for
30s.</div>
<div>During the 30s, if the callee be online, opensips
will send the invite to it.</div>
<div><br>
</div>
<div><span style="font-family: "" microsoft=""
yahei="" ui'";="" font-size:="" 14px;="" color:=""
rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,=""
font-weight:="" normal;="" font-style:=""
normal;text-decoration:="" none;'="">
$avp(timeout) = 30 ;<br>
while( !lookup("location","m") ){<br>
if( $avp(timeout)==0 ){<br>
send_reply("420","Can not find the callee!");<br>
exit;<br>
}<br>
sleep("1");<br>
$avp(timeout) = $avp(timeout)-1;<br>
}</span></div>
<div><br>
</div>
<div>This works well, the only problem is the caller can
not cancel it during that 30s</div>
<div><span style="font-family: "" microsoft=""
yahei="" ui'";="" font-size:="" 14px;="" color:=""
rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,=""
font-weight:="" normal;="" font-style:=""
normal;text-decoration:="" none;'="">t_cancel_branch()
only can be used in onreply_route, but at that time,
callee is offline.</span></div>
<div><span style="font-family: "" microsoft=""
yahei="" ui'";="" font-size:="" 14px;="" color:=""
rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,=""
font-weight:="" normal;="" font-style:=""
normal;text-decoration:="" none;'=""><br>
</span></div>
<div><span style="font-family: "" microsoft=""
yahei="" ui'";="" font-size:="" 14px;="" color:=""
rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,=""
font-weight:="" normal;="" font-style:=""
normal;text-decoration:="" none;'="">My question is :</span></div>
<div><span style="font-family: "" microsoft=""
yahei="" ui'";="" font-size:="" 14px;="" color:=""
rgb(0,="" 0,="" 0);="" background-color:="" rgba(0,=""
font-weight:="" normal;="" font-style:=""
normal;text-decoration:="" none;'="">Is it possible
that terminate a request in route block?</span></div>
<div><br>
</div>
<div><br>
</div>
<hr style="width: 210px; height: 1px;" size="1"
align="left" color="#b5c4df">
<div><span>
<div style="MARGIN: 10px; FONT-FAMILY: verdana;
FONT-SIZE: 10pt">
<div><a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:merlin.li@tsingch.com">merlin.li@tsingch.com</a></div>
</div>
</span></div>
</div>
</div>
</blockquote>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a moz-do-not-send="true" 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>
</pre>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<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>
</pre>
</blockquote>
<br>
</body>
</html>