[OpenSIPS-Users] how to cancel an INVITE before the callee receive it?

Liviu Chircu liviu at opensips.org
Wed Mar 4 12:57:45 CET 2015


merlin,

The SIP CANCEL must be sent by the caller, since "he wants to undo his 
INVITE request", not by the proxy. In order to break the call on the UAC 
side, have your proxy send him a generic "404 - Not Found" SIP reply, 
after your have done enough lookup() tries:

...
t_reply("404", "Not Found");
exit;
...

Best regards,

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com

On 04.03.2015 13:30, merlin.li at tsingch.com wrote:
> Hi Chircu,
>
> Thanks for your reply.
> The 30s just my test value.
> And maybe i didn't discribe my problem clearly.
> I can understand that t_newtran() can create the transaction first , 
> and i already did it before i send the first email.
> But as i said, the caller still can not cancel it, because i don't 
> know how to do it.
> t_cancel_branch() only can be used in onreply_route but at that  time, 
> callee is offline.
>
> Here is my cancel processing in the route , would you please tell me 
> how can i cancel the invite which still in the while loop?
>
>       # CANCEL processing
>         if (is_method("CANCEL"))
>         {
>                 if (t_check_trans()){
>                             t_relay();
>                             exit;
>                         }
>
>         }
>
> ------------------------------------------------------------------------
> merlin.li at tsingch.com
>
>
>     Message: 1
>     Date: Tue, 03 Mar 2015 14:57:32 +0200
>     From: Liviu Chircu <liviu at opensips.org>
>     Subject: Re: [OpenSIPS-Users] how to cancel an INVITE before the
>     callee receive it?
>     To: users at lists.opensips.org
>     Message-ID: <54F5AFBC.1000200 at opensips.org>
>     Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>     Hello merlin,
>     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.
>     That being said, here is what you should add in order to make it work:
>     t_newtran();
>     ...
>     while (...) {
>          if (t_was_cancelled()) {
>              t_reply("487", "Request Cancelled");
>              exit;
>          }
>          ...
>     }
>     Best regards,
>     Liviu Chircu
>     OpenSIPS Developer
>     http://www.opensips-solutions.com
>     On 03.03.2015 10:45, merlin.li at tsingch.com wrote:
>     > Hi,
>     >
>     > Or is there a way i can break the while loop in the route block
>     when i
>     > receive the CANCEL request?
>     >
>     >
>     ------------------------------------------------------------------------
>     > merlin.li at tsingch.com
>     >
>     >     *From:* merlin.li at tsingch.com <mailto:merlin.li at tsingch.com>
>     >     *Date:* 2015-03-03 16:14
>     >     *To:* users <mailto:users at lists.opensips.org>
>     >     *Subject:* how to cancel an INVITE before the callee receive it?
>     >     Hi all,
>     >
>     >     Let me describe my scenario first.
>     >
>     >     if the callee is not online, opensips will wait for 30s.
>     >     During the 30s, if the callee be online, opensips will send the
>     >     invite to it.
>     >
>     >        $avp(timeout) = 30 ;
>     >                             while( !lookup("location","m") ){
>     >                                    if( $avp(timeout)==0 ){
>     > send_reply("420","Can not find the callee!");
>     >                                     exit;
>     >                                 }
>     >                                 sleep("1");
>     >                                 $avp(timeout) = $avp(timeout)-1;
>     >                             }
>     >
>     >     This works well, the only problem is the caller can not
>     cancel it
>     >     during that 30s
>     >     t_cancel_branch() only can be used in onreply_route, but at that
>     >     time, callee is offline.
>     >
>     >     My question is :
>     >     Is it possible that terminate a request in route block?
>     >
>     >
>     >
>     ------------------------------------------------------------------------
>     >     merlin.li at tsingch.com
>     >
>     >
>     >
>     > _______________________________________________
>     > Users mailing list
>     > Users at lists.opensips.org
>     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     -------------- next part --------------
>     An HTML attachment was scrubbed...
>     URL:
>     <http://lists.opensips.org/pipermail/users/attachments/20150303/a9747213/attachment-0001.htm>
>     ------------------------------
>     Message: 2
>     Date: Tue, 03 Mar 2015 15:15:23 +0200
>     From: Liviu Chircu <liviu at opensips.org>
>     Subject: Re: [OpenSIPS-Users] how to cancel an INVITE before the
>     callee receive it?
>     To: users at lists.opensips.org
>     Message-ID: <54F5B3EB.9050808 at opensips.org>
>     Content-Type: text/plain; charset="windows-1252"; Format="flowed"
>     The previous solution won't work because you can't call
>     t_was_cancelled() in the main route... You should:
>     1) set $T_fr_timeout and $T_fr_inv_timeout to 1
>     2) t_on_failure(...) [1]
>     3) t_relay() to a bogus gateway [2]
>     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().
>     [1] : http://www.opensips.org/Documentation/Script-Routes-2-1#toc3
>     [2] : http://www.opensips.org/html/docs/modules/2.1.x/tm.html#trelay-1
>     On 03.03.2015 14:57, Liviu Chircu wrote:
>     > Hello merlin,
>     >
>     > 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.
>     >
>     > That being said, here is what you should add in order to make it
>     work:
>     >
>     > t_newtran();
>     > ...
>     > while (...) {
>     >     if (t_was_cancelled()) {
>     >         t_reply("487", "Request Cancelled");
>     >         exit;
>     >     }
>     >     ...
>     > }
>     >
>     > Best regards,
>     > Liviu Chircu
>     > OpenSIPS Developer
>     > http://www.opensips-solutions.com
>     > On 03.03.2015 10:45, merlin.li at tsingch.com wrote:
>     >> Hi,
>     >>
>     >> Or is there a way i can break the while loop in the route block
>     when
>     >> i receive the CANCEL request?
>     >>
>     >>
>     ------------------------------------------------------------------------
>     >> merlin.li at tsingch.com
>     >>
>     >>     *From:* merlin.li at tsingch.com <mailto:merlin.li at tsingch.com>
>     >>     *Date:* 2015-03-03 16:14
>     >>     *To:* users <mailto:users at lists.opensips.org>
>     >>     *Subject:* how to cancel an INVITE before the callee
>     receive it?
>     >>     Hi all,
>     >>
>     >>     Let me describe my scenario first.
>     >>
>     >>     if the callee is not online, opensips will wait for 30s.
>     >>     During the 30s, if the callee be online, opensips will send the
>     >>     invite to it.
>     >>
>     >>          $avp(timeout) = 30 ;
>     >>                             while( !lookup("location","m") ){
>     >>                                    if( $avp(timeout)==0 ){
>     >> send_reply("420","Can not find the callee!");
>     >>                                     exit;
>     >>                                 }
>     >>                                 sleep("1");
>     >>                                 $avp(timeout) = $avp(timeout)-1;
>     >>                             }
>     >>
>     >>     This works well, the only problem is the caller can not
>     cancel it
>     >>     during that 30s
>     >>     t_cancel_branch() only can be used in onreply_route, but at
>     that
>     >>     time, callee is offline.
>     >>
>     >>     My question is :
>     >>     Is it possible that terminate a request in route block?
>     >>
>     >>
>     >>
>     ------------------------------------------------------------------------
>     >>     merlin.li at tsingch.com
>     >>
>     >>
>     >>
>     >> _______________________________________________
>     >> Users mailing list
>     >> Users at lists.opensips.org
>     >> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     >
>     >
>     >
>     > _______________________________________________
>     > Users mailing list
>     > Users at lists.opensips.org
>     > http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     -------------- next part --------------
>     An HTML attachment was scrubbed...
>     URL:
>     <http://lists.opensips.org/pipermail/users/attachments/20150303/31768207/attachment-0001.htm>
>     ------------------------------
>     Message: 3
>     Date: Tue, 3 Mar 2015 17:02:44 +0100
>     From: Adri? Vidal <adriavidal at gmail.com>
>     Subject: Re: [OpenSIPS-Users] CDRtool 9.3 web interface
>     To: OpenSIPS users mailling list <users at lists.opensips.org>
>     Message-ID:
>     <CAFYw3-dR_RcmaN=yXsm3gRB2urSWw325ANAcvm+VE_-kaoA15A at mail.gmail.com>
>     Content-Type: text/plain; charset="utf-8"
>     2015-03-03 11:30 GMT+01:00 Tijmen de Mes <tijmen at ag-projects.com>:
>     > Hi,
>     >
>     > Clicking on the icons does not work. If you click on the input
>     field you
>     > should get a date picker.
>     >
>     > If you don?t get it please take a look at the webbrowsers
>     console if get
>     > any error or exception.
>     >
>     > Best regards,
>     >
>     > Tijmen de Mes
>     >
>     I see no input field to click on
>     https://www.dropbox.com/s/w55ynwrc1kbps6d/Captura%20de%20pantalla%202015-03-03%2017.02.14.png?dl=0
>     -- 
>     --
>     Adri? Vidal
>     T. 93 150 31 80 | M 607 28 89 56
>     @ adria at gmail.com
>     www www.xpreme.net | centralitaip.xpreme.net
>     twitter xpreme_it
>     <https://twitter.com/intent/user?screen_name=xpreme_it>
>     -------------- next part --------------
>     An HTML attachment was scrubbed...
>     URL:
>     <http://lists.opensips.org/pipermail/users/attachments/20150303/7b382bc0/attachment.htm>
>     ------------------------------
>     _______________________________________________
>     Users mailing list
>     Users at lists.opensips.org
>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>     End of Users Digest, Vol 80, Issue 6
>     ************************************
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20150304/fa4efbc4/attachment-0001.htm>


More information about the Users mailing list